This is a strange one. I changed something (not sure what) and now my app's view doesn't compile at runtime.
The view itself is strongly typed:
<%@ Page Language="C#"
MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<MyNamespace.OperatorModel>" %>
When I visit the page, it fails to compile, saying:
CS1061: 'object' does not contain a definition for 'Log' and no extension method 'Log' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Pretty standard error. The corresponding source code line is:
<%= Html.HiddenFor(model => model.Log) %>
When I look at the compiler-generated code, I see that the base class of the view is not strongly typed:
[System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
public class views_operator_create_aspx
: global::System.Web.Mvc.ViewPage, // NOT STRONGLY TYPED
System.Web.SessionState.IRequiresSessionState,
System.Web.IHttpHandler {
So my question is, what is causing the view compiler to ignore my Inherits
attribute on the view definition?
I should point out that other views on the same controller are working, and they have exactly the same page declaration as I've shown above.
EDIT Does anyone know where the generated source code file lives, assuming it is persisted somewhere?
EDIT I found the culprit (in my answer below) but I've no idea why this is happening. If someone can explain I'd appreciate it!