In MVC2 we have a custom base class
public class OurViewPage<TModel,TPresentationModel> : ViewPage<TModel>
so we have in the view a Model property and a PresentationModel property…
Our Aspx file starts with
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Our.Master"
Inherits="OurViewPage<IndexModel,IndexPresentationModel>" %>
With the MVC3 Razor view engine, would something equivalent be possible?
- from which base class should we inherited.
- how do you specify in the view which classes a view uses (equivalent of the Page directive)?
Your class should derive from
System.Web.Mvc.WebViewPage<TModel>In your view file you would add the following line to the top:
Note that you should not use the
@modelsyntax if you have a base class with two generic parameters.