ASP.NET MVC 3 Beta Support for Code Runs before Views and Strongly Typed Models in Razor Views
Code that Runs Before Views Run
In ASP.NET MVC 3 Beta, we can add a file named _viewstart.cshtml in the views directory and this will be shared among the all views with in the Views directory. The below code in the _viewstart.cshtml, sets the Layout page for every Views in the Views folder
- @{
- Layout = "~/Views/Shared/_Layout.cshtml";
- }
You can put a _viewstart.cshtml file on the any subfolders of Views folder and it will be shared only for that sub folder.
Specify Strongly Typed Models in Razor Views
In ASP.NET MVC 3 Beta, we can simply specify the strongly typed model using the following syntax
- @model Models.RegisterModel
In the above syntax, we have specified RegisterModel in the Models namespace as strongly typed model for our Razor View.