Wednesday, 5 August 2015

ASP.NET MVC - Create a view.(How to create a view in ASP.NET MVC)

There are few other ways to create a View, however if you have an action method and do not have corresponding View, right click the Action method and select Add View.


write the View name ,select the template.



  • Empty (without model) – generally used to render static content to the browser 
  • Create – applicable only when we are going to add a Create form for the model – need to select a model 
  • Details – applicable only when we are going to show the details of a model – need to select a model 
  • Delete – applicable only when we are going to delete a model record – need to select a model
  • Edit – applicable only when we are going to edit a model record – need to select a model 
  • List – applicable only when we are going to list model records 
  • Empty - applicable only when we are going to create a view with a model and want to scaffold the HTML code based on model property.
Keep the Use a layout page checkbox checked as we do not want to select any other master page (_Layout.cshtml) and want to use default. 
Now, click Add 
It will create a Index.cshtml view in the Views/Default folder and the code would look like
/Views/Default/Index.cshtml  

@{    
    ViewBag.Title = "Index"; 
  } 

<h2>Index</h2> 

What do you think?
I hope you will enjoy the create View while programming with Asp.Net MVC. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

No comments:

Post a Comment