Problems with Site.Master and ASP.NET MVC – Education Career Blog

i’m trying to make my site master page (views/shared/site.master) strongly typed.

eg. Inherits=”TestProject.Mvc.Views.Shared.Site”

I can’t seem to get this work. Once i make the site.master page strongly, typed, Visual Studio seems to ‘loose’ what <%= Html.XXX %> is. Also, the page throws an error when i try to display the default index route.

The SiteMasterViewData class exists in the views/shared/ folder and has been included at the top of the master page via..

<%@ Import Namespace="TestProject.Mvc.Views.Shared"%>

Can this be done? is there a better way to do this?


Damn – found my own answer.

All masterpages in the ASP.NET MVC v1. need to inherit from:

<%@ Master 
    Inherits="System.Web.Mvc.ViewMasterPage" %>

so if u want to strongly type it, you can do this.

<%@ Master 
    Inherits="System.Web.Mvc.ViewMasterPage<SiteMasterViewData>" %>

HTH’s other peeps 🙂

Leave a Comment