Simple Asp.Net MVC Hello World Example (Program)

  Total Views : 6713
  Comments : 1
 
  Keywords : Asp.net mvc hello world example, Create hello world program in asp.net mvc application, Hello world application in asp.net mvc,

Here we will learn step by step process to create simple hello world applicaiton program in asp.net mvc with example.

Asp.Net MVC Hello World Example

To create hello world example in asp.net mvc lets start with creating new ASP.NET MVC application. For this hello world example in asp.net mvc we are using Visual studio 2012.

 

using visual studio 2012 for asp.net mvc application

 

Click on New Project if you getting started with Start Page.  Otherwise you can go from Menu by selecting File àNew àThen select Project.

 

select new project for asp.net mvc application

 

After that you will see new dialog will pop up for selecting your Template and Project type. From Templates select Visual C# inside that select Web and then project type select ASP.NET MVC 4 Web Application and here we are giving name as “Tutorial1” then finally click on ok button.

 

seelct asp.net mvc web application while creating application

 

After that a new dialog will pop up for selecting Project Template in that select Basic template and from view engine we will choose Razor and then click on ok button.

 

Adding basic template for mvc application

 

After create application our basic asp.net mvc application project structure will be like as shown following image.

 

Our basic asp.net mvc application structure will be like as shown

Here we will learn simple “Hello world” example in asp.net mvc for that let’s start with adding controller with name Home. For adding Controller just Right click on Controller folder then select Add from List inside that select Controller.

 

Adding controller in asp.net mvc application

 

After selecting a new dialog will pop up for asking Controller name and Template. Here we will give controller name as HomeController and in template we will select Empty MVC Controller and click on Add button. Once we add our controller that will be like as shown following image

 

Once we add controller to mvc application our project structure will be like as shown

 

Now we just need to add view for the controller (HomeController) whatever we added in our application. Open our HomeController file and just right click in inside controller anywhere like as shown following image

 

Adding view to controller by right click in asp.net mvc application

 

After Clicking on Add view a new dialog pop up will open for view configuration like as following image

 

Adding view for controller in asp.net mvc applicaiton

 

Here we will provide View name as Index and click on Add button once we add view our Project structure will be like as shown following image

 

After adding view in asp.net mvc application our project structure

Now open our Index view and write message "Hello world" like as shown following image

 

Adding hello world code in view in asp.net mvc

 

After adding message on view now let’s save application and run it. For running we must provide URL to it such as Home/Index. Generally our url formats will be like "Localhost:anyport/Controller name/Action result name

 

e.g. http://localhost:12024/home/index

 

Once we run application our asp.net mvc application simple hello world output will be like as shown below

 

simple asp.net mvc hello world example or application output

 Comments (1)

  • shiv tutlane registered profile image
     
    shiv   Reply

    HI good technical resource for beginner and Advance. Thanks

     Feb 11, 2016

Leave a comment

  • Default Tutlane User