Mvc 5 ViewPage <T> becomes non-generic ViewPage at compilation

I update the site by creating a new ASP.Net Mvc 5 skeleton and then delete the content. Currently everything seems to work, except for strongly typed views. All access properties Modeldo not work, and it is obvious that an uncontrolled controller is being used.

Example:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MySite.Models.MyViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <h1><%= Model.Title %></h1>
</asp:Content>

I get the error "object" does not contain a definition for "Title" and no extension method ...

The transition to the definition in Model takes me here:

namespace System.Web.Mvc
{
    // Summary:
    //     Represents the properties and methods that are needed to render a view as
    //     a Web Forms page.
    [FileLevelControlBuilder(typeof(ViewPageControlBuilder))]
    public class ViewPage : Page, IViewDataContainer
    {
        <snip>
        public object Model { get; }

Why is he choosing the wrong item?

The project was created as an MVC4 project, and then upgraded to MVC5 using nuget before adding any code.

+4
2

specficially View/web.config, config .

  <system.web>
    <compilation>
      <assemblies>
        <add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>

    <pages pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, 
       Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
           pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, 
       Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
       userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, 
       Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
           >
      <namespaces>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Routing"/>
      </namespaces>
    </pages>
  </system.web>
+1

All Articles