Getting Started with ASP.NET MVC 5 using Visual Basic

This tutorial is the first in a series of a Visual Basic versions of the Introduction to ASP.NET MVC 5 tutorials published on the www.asp.net site. The original series, produced by Scott Guthrie (twitter @scottgu ), Scott Hanselman (twitter: @shanselman ), and Rick Anderson ( @RickAndMSFT ) was written using the C# language. My versions keep as close to the originals as possible, changing only the coding language. The narrative text is largely unchanged from the original and is used with permission from Microsoft.

This tutorial series will teach you the basics of building an ASP.NET MVC 5 Web application using Visual Studio 2013 and Visual Basic.  A Visual Studio Express For Web project with VB source code is available to accompany this series which you can download.

The tutorial series comprises 11 sections in total. They cover the basics of web development using the ASP.NET MVC framework and the Entity Framework for data access. They are intended to be followed sequentially as each section builds on the knowledge imparted in the previous sections. The navigation path through the series is as follows:

  1. Getting Started
  2. Adding a Controller
  3. Adding a View
  4. Adding a Model
  5. Creating a Connection String and Working with SQL Server LocalDB
  6. Accessing Your Model's Data from a Controller
  7. Examining the Edit Methods and Edit View
  8. Adding Search
  9. Adding a New Field
  10. Adding Validation
  11. Examining the Details and Delete Methods

1. Getting Started

Start by installing and running Visual Studio Express 2013 for Web or Visual Studio 2013.

Visual Studio is an IDE, or integrated development environment. Just like you use Microsoft Word to write documents, you'll use an IDE to create applications. In Visual Studio there's a toolbar along the top showing various options available to you. There's also a menu that provides another way to perform tasks in the IDE. (For example, instead of selecting New Project from the Start page, you can use the menu and select File > New Project.)

Beginning MVC

Creating Your First Application

Click New Project, then select Visual C# on the left, then Web and then select ASP.NET Web Application. Name your project "MvcMovie" and then click OK.

Beginning MVC

In the New ASP.NET Project dialog, click MVC and then click OK.

Beginning MVC

Visual Studio uses a default template for the ASP.NET MVC project you just created, so you have a working application right now without doing anything! This is a simple "Hello World!" project, and it's a good place to start your application.

Beginning MVC

Click F5 to start debugging. F5 causes Visual Studio to start IIS Express and run your web application. Visual Studio then launches a browser and opens the application's home page. Notice that the address bar of the browser says localhost:port# and not something like example.com. That's because localhost always points to your own local computer, which in this case is running the application you just built. When Visual Studio runs a web project, a random port is used for the web server. In the image below, the port number is 1804. When you run the application, you'll probably see a different port number.

Beginning MVC

Right out of the box this default template gives you Home, Contact and About pages. The image above doesn't show the HomeAbout and Contact links. Depending on the size of your browser window, you might need to click the navigation icon to see these links.

Beginning MVC

Beginning MVC

The application also provides support to register and log in. The next step is to change how this application works and learn a little bit about ASP.NET MVC. In the next section, you will look at adding the 'C' part of MVC - a Controller

 

Date Posted:
Last Updated:
Posted by:
Total Views to date: 58093

9 Comments

- Clive Chinery

Well done Mike!

- Jeff Bowman

Good job, Mike.

We must preserve our culture and heritage ;-)

- Tim

Great series Mike! Any leads on books covering MVC 5 and VB or books that might show code for both? I know the Wrox Professional MVC 5 is due out this month but haven't found anything stating whether it will include both C# and VB code.

- Mike

@Tim,

I'm not aware of any VB-only MVC books. Previous editions of the Wrox MVC books have been C# only, so I doubt that will change with the next edition.

I'm just finishing a port of Tom Dykstra's EF6 and MVC5 tutorials (http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc) to VB. They should be ready in a day or two.

- Joe McGrath

thank-you.

I'm a vb guy that converts C# code when I need.

I read most of Adam Freeman "Pro Asp.net mvc4"
And this now gonna help me a lot

hmm.. they get into ninject and mention unity
hmm.. I not much of a jquery javascript dude
I a formsengineview type guy I guess.

thinking my .net forms viewstate objectivedatasource type background along with this site gonna help me get through stuff .. hoping dbcontext help me avoid jquery hill (for bit anyways)

excuse if nuttin I said makes sense... for I not much of a 'client' script coder.. this may help me at least bridge my asp.net aspx to razor engine .. and avoid jquery for bit (from at least getting a grid to act like a gridview via helpers n stuff) .. and maybe start with jquery via validators I saw you mention somewhere...

just typin my thoughts outloud.. I'll prob reread after looking closer at this site and go 'ahhh' what was I saying!

- Bill K

Have programmed using VB6, .net is a new experience. Excited to get started.

- Raphael Fonua

The set up and delivery is both concise and clear everything I need when I am trying to learn and understand a tutorial. Thank you very much.

Regards

Raph

- Dan H

I've also looked for a book that covers MVC and VB.Net. The only one I found was "ASP.NET MVC Framework Unleashed" by Stephen Walther but it's from 2009 so I'm concerned that it's too out-dated. Anyone have any other suggestions?

- Mike

@Dan H,

I didn't know that Stephen Walther's book included VB examples. It covers MVC 1.0 and is quite old. A large chunk of the basic framework is still the same but the preferred view engine is Razor and data access is generally done using the Entity Framework rather than Linq to SQL these days.

Recent Comments

Gayan 7/3/2015 6:20 AM
In response to 7 C# 6.0 Features That Every ASP.NET Developer Should Know About
Great Article thanks...

Semil 7/1/2015 7:03 AM
In response to iTextSharp - Drawing shapes and Graphics
I have created a rectangle using above methode. Now I want to add a text in the center of this How I...

Satyabrata Mohapatra 6/30/2015 6:12 PM
In response to Reading Excel Files Without Saving To Disk In ASP.NET
Ahh.....this is awesome. Happy to see after a long time you wrote a article on web form :D...

Marty 6/30/2015 7:16 AM
In response to Posting Data With jQuery AJAX In ASP.NET Razor Web Pages
Mike, you're the Man! Another great article. So incredibly helpful. I'm definitely going to buy your...

Rohan 6/30/2015 5:32 AM
In response to ASP.NET MVC 5 with EF 6 - Working With Files
Very good and helpful tutorial. Thanks. Just wanted to know what would be the max file size limit we...

Fernando 6/30/2015 1:59 AM
In response to Programmatically accessing data from DataSource controls
What if I want to pass parameters natively using the DataSourceSelectArguments object, instead of be...

pankaj 6/29/2015 3:13 PM
In response to How to retain carriage returns or line breaks in an ASP.NET web page
very nice i'm use this in my code thank you.... ...

Mike 6/29/2015 2:22 AM
In response to MVC 5 with EF 6 in Visual Basic - Sorting, Filtering and Paging
This is the first example that I have found that works....

Marty 6/28/2015 4:57 AM
In response to Posting Data With jQuery AJAX In ASP.NET Razor Web Pages
Mike, what if I don't want to render back the text to the browser, but I want to send it some other...

Mike 6/27/2015 4:00 PM
In response to Migrating Classic ASP To ASP.NET Razor Web Pages Part One- Razor Syntax And Visual Basic
have you used any of the code converters to convert classic asp to c#? If so, which one do you have...