I have a simple view in which I am trying to access the Model properties. None of the model properties are available at this time (this is the problem).
If I use a <%= Model.blah %>
then you can see that the model properties are available.
In the last photo you will now see that I can access the Model properties that I was trying to ac开发者_JS百科cess in the first photo.
An error will be thrown if viewing this page if you don't first do <%= with the model.
CS1061: 'object' does not contain a definition for 'User' and no extension method 'User' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
So why is this happening?
Your view inherits System.Web.Mvc.ViewMasterPage<AuthModel>
which of course is wrong as it is an aspx
page. Make it inherit from System.Web.Mvc.ViewPage<AuthModel>
and it should work:
<%@ Page
Language="C#"
MasterPageFile="~/Views/Shared/Base.Master"
Inherits="System.Web.Mvc.ViewPage<AuthModel>"
%>
精彩评论