ASP.Net MVC 5 Using Visual Basic: Getting Started

This article explains how to create an ASP.Net MVC 5 Web Application using Visual Basic in Visual Studio 2013.

Introduction

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#.

In 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:

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>@ViewBag.Title - My Cricketer App</title>

    @Styles.Render("~/Content/css")

    @Scripts.Render("~/bundles/modernizr")

 

</head>

<body>

    <div class="navbar navbar-inverse navbar-fixed-top">

        <div class="container">

            <div class="navbar-header">

                <button type="button" class="navbar-toggle" 
data-toggle="collapse" data-target=".navbar-collapse">

                    <span class="icon-bar"></span>

                    <span class="icon-bar"></span>

                    <span class="icon-bar"></span>

                </button>

                @Html.ActionLink("Mvc Cricketer""Index""Home"
New With {.area = ""}, New With {.class = "navbar-brand"})

            </div>

            <div class="navbar-collapse collapse">

                <ul class="nav navbar-nav">

                    <li>@Html.ActionLink("Home""Index""Home")</li>

                    <li>@Html.ActionLink("About""About""Home")</li>

                    <li>@Html.ActionLink("Contact""Contact""Home")</li>

                </ul>

                @Html.Partial("_LoginPartial")

            </div>

        </div>

    </div>

    <div class="container body-content">

        @RenderBody()

        <hr />

        <footer>

            <p>© @DateTime.Now.Year - Mvc Cricketer Application</p>

        </footer>

    </div>

 

    @Scripts.Render("~/bundles/jquery")

    @Scripts.Render("~/bundles/bootstrap")

    @RenderSection("scripts", required:=False)

</body>

</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 the 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

Summary

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.