Create Your First MVC Project

Let's start creating your first MVC Project.

Open Visual Studio 2010+, and then click on "File" -> "New" -> "Project..." and select the template "ASP.Net MVC 4 Web Application" from the available list.

1.jpg

2.jpg

Give the project a name and location to save the project and give a solution name then click "OK".

That's it, your project will be created. A default code behind page will be opened for you, "HomeController.cs".

3.jpg

Hit F5 from your keyboard, the local host web page will be loaded with a default theme for you.

4.jpg

Now if you observe the "HomeController.cs" screenshot above, we will see some red boxes placed near "ViewBag.Message".

Those are the customized messages that will be displayed on your web page. Just go on and edit the first "ViewBag.Message" to

some text like, "Hello World!" and re-run the web page.

5.jpg

Here the new text is used, we have created our first MVC 4 project.

What is ViewBag?

ViewBag is a property that belongs to the Controller and View only, to pass data between Controllers and Views.

ViewBag allows an object to dynamically have properties added to it. We will discuss this more later.

Let's move to the next topic.

Thank You!