ASP.Net MVC 5 Using Visual Basic: Getting Started


There are two technologies available to create ASP.NET Web Applications that use the MVC Project Template: The first one is Visual C# and the second one is Visual Basic. Since I have created many articles regarding MVC in Visual C#, you can also refer to them by Creating MVC in Visual C#.

Here, I am creating a series of articles in which you'll learn to work with the ASP.NET MVC 5 Application using Visual Basic. In the first article, we'll learn to create the ASP.NET MVC Application in Visual Basic.

So, let's start with the following procedure:

  • Creating MVC 5 Application
  • Working with MVC Application
  • Running the Application

Creating MVC 5 Application

In this section, we'll create the ASP.NET Web Application using MVC Project Template. We'll create it using Visual Basic. Use the following procedure.

Step 1: Open Visual Studio 2013 and click on "New Project"

Visual Studio 2013 Start Page

Step 2: In the left pane, expand the Other Templates and select the Web tab after expanding the Visual Basic tab. Just select the "ASP.NET Web Application" and enter the name for it.

Creating Web Application

Step 3: Select the MVC Project Template in the next "One ASP.NET" Wizard.

MVC Project Template in VS 2013

Visual Studio creates the application with the MVC and adds some files and folders in the solution. After creating the entire project, it provides the Project_Readme.html file with which you can find various articles and blogs related to MVC.

Project Readme File

Working with MVC Application

In this section, we'll edit the MVC application as per our project. By default a MVC application uses its default settings and if we want to develop the application as per our requirements then we need to change the application as we need. Use the following procedure to do that.

Step 1: Open the _Layout.cshtml file that provides the master layout for the application

Application Layout File in MVC

Step 2: Change the code using the following highlighted code:

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <meta charset="utf-8" />  
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">  
  6.     <title>@ViewBag.Title - My Cricketer App</title>  
  7.     @Styles.Render("~/Content/css")  
  8.     @Scripts.Render("~/bundles/modernizr")  
  9. </head>  
  10. <body>  
  11.     <div class="navbar navbar-inverse navbar-fixed-top">  
  12.         <div class="container">  
  13.             <div class="navbar-header">  
  14.                 <button type="button" class="navbar-toggle"   
  15. data-toggle="collapse" data-target=".navbar-collapse">  
  16.                     <span class="icon-bar"></span>  
  17.                     <span class="icon-bar"></span>  
  18.                     <span class="icon-bar"></span>  
  19.                 </button>  
  20.                 @Html.ActionLink("Mvc Cricketer""Index""Home",   
  21. New With {.area = ""}, New With {.class = "navbar-brand"})  
  22.             </div>  
  23.             <div class="navbar-collapse collapse">  
  24.                 <ul class="nav navbar-nav">  
  25.                     <li>@Html.ActionLink("Home""Index""Home")</li>  
  26.                     <li>@Html.ActionLink("About""About""Home")</li>  
  27.                     <li>@Html.ActionLink("Contact""Contact""Home")</li>  
  28.                 </ul>  
  29.                 @Html.Partial("_LoginPartial")  
  30.             </div>  
  31.         </div>  
  32.     </div>  
  33.     <div class="container body-content">  
  34.         @RenderBody()  
  35.         <hr />  
  36.         <footer>  
  37.             <p>© @DateTime.Now.Year - Mvc Cricketer Application</p>  
  38.         </footer>  
  39.     </div>  
  40.     @Scripts.Render("~/bundles/jquery")  
  41.     @Scripts.Render("~/bundles/bootstrap")  
  42.     @RenderSection("scripts", required:=False)  
  43. </body>  
  44. </html> 

In the code, we have done some changes as per our project requirements.

Step 3: Save the application.

Running the Application

Now press Ctrl+F5 or F5 to debug the application. It starts IIS Express that will run the application in your local computer. You can check the browser address bar that shows the http://localhost:port number/ because the localhost always points to the local computer. The port number is different and chosen randomly.

Mvc 5 Home Page

MVC 5 uses the Bootstrap template that provides responsiveness to the application. Your MVC application is a responsive application, which means that even though you resize your browser, the content also resizes and fits the browser screen.

Responsive MVC 5 Home Page

Now you can click on the icon to check the menu bar.

Responsive Menu in MVC 5


This article described how to create an ASP.NET Web Application in the MVC 5 Project Template using Visual Basic. We'll learn to work with the controller in the next part of this tutorial series. Thanks for reading.

Similar Articles