Back To FAQ

ASP.NET MVC View detail

Every view in ASP.NET MVC is derived from WebViewPage. The following figure shows class hierarchy.

View class hierarchy

Web.config file in Views folder, indicate that base type of every page is System.Web.Mvc.WebViewPage as shown below:

Base type of razor view:
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing" />
        <add namespace="MVC_BasicTutorials" />

So, you can use any of the method and properties of WebViewPage and its' base class such as WebPageBase, WebPageRenderingBase & WebPageExecutingBase starting with @symbol.

WebViewPage class includes following members.

Property Description
Ajax Gets or sets the AjaxHelper object that is used to render HTML using Ajax.
Html Gets or sets the HtmlHelper object that is used to render HTML elements.
Model Gets the Model property of the associated ViewDataDictionary object.
ViewBag Gets the view bag.
ViewContext Gets or sets the information that is used to render the view.
ViewData Gets or sets a dictionary that contains data to pass between the controller and the view.

Visit MSDN for detailed information on WebViewPage members.

Thus, when you use HtmlHelper class using @Html, you actually use HtmlHelper class assigned to Html property of WebViewPage.