Articles → ASP .NET MVC → Strongly Type Views In Mvc

Strongly Type Views In Mvc






Strongly Type View





How To Create A Strongly Type View




  1. Right click on the View → Home folder and click on Add → view..
  2. Picture showing adding the view in the project in visual studio

    Click to Enlarge

  3. A pop up window appears. From the window, select ‘Empty’ from ‘Template’ drop down
  4. Picture showing the Add View view for adding the new view

    Click to Enlarge

  5. Once you select the option, ‘Model’ drop down gets enabled (see the following figure)
  6. Picture showing selecting the modal class for the view

    Click to Enlarge

  7. Select the model and click on ‘Add’.


@model strongly_type_views.Models.MyModel

@{
    ViewBag.Title = "View2";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<h2>View2</h2>



Advantages Of Strongly Type View


  1. In visual studio, you get an advantage of intellisense.
  2. Errors could be checked at compile time.



Posted By  -  Karan Gupta
 
Posted On  -  Saturday, December 26, 2015
 
Updated On  -  Monday, October 2, 2017

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250