I have a master page that serves as a template for a few related pages. Both the master page and the views that use it are strongly typed, and they all use the same view model data type. The declarations look like this:
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage<SearchDataModel>" MasterPageFile="~/Views/Shared/InSpire.Master" %> ... <%@ Page Language="C#" MasterPageFile="Search.Master" Inherits="System.Web.Mvc.ViewPage<SearchDataModel>" %> ...
Access the model works just fine on the views, but trying to access properties of the model from the master page results in this error message:
CS1061: ‘object‘ does not contain a definition for ‘Query’ and no extension method ‘Query’ accepting a first argument of type ‘object‘ could be found.
Note the part in bold: it thinks my model is of type object! This is despite the fact that I told it the type when I declared the page. If I first cast the Model property on the master page to the view model type, it works fine. Anyone know what’s going on?