Could not load type 'System.Web.Mvc.ViewUserControl'

前端 未结 4 1269
盖世英雄少女心
盖世英雄少女心 2021-01-02 06:52

I\'m trying to deploy ASP.NET MVC 2 project (VS2010) to Win Server 2008 R2

It works perfectly on dev machine. But strange error occurs at Server 2008 R2: When .ascx

相关标签:
4条回答
  • 2021-01-02 07:22

    Could not find why but the following helped (web.config):

    <pages
             pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
             pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
             userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    

    Initially found similar for asp.net mvc 1

    0 讨论(0)
  • 2021-01-02 07:22

    Could be messed up ASP.NET MVC installation on the server. I suggest uninstalling MVC and reinstalling with Web Platform Installer. I had problems too when I installed using the downloaded setups files, so I removed everything and went with the Web Platform Installer.

    Another suggestion would be to make a new fresh server box - can be virtual - and try there.

    Also rebuilding solution could help and checking out that web.config is ok too.

    Also try if MvcDiagnostics.aspx tool shows any abnormalities. Check out this blog post

    Let us know if anything helps.

    0 讨论(0)
  • 2021-01-02 07:23

    I had similar problem. There are several important points

    1. Required space between the brackets and type name.
    2. Need cast model for your model type.

    Here's what I got

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl <MyNamespace.MyModel>" %>
    <%@ Import Namespace="MyNamespace" %>
    <% var model = (MyModel)Model; %>
    
    <h1><% model.MyField %></h1>
    
    0 讨论(0)
  • 2021-01-02 07:25

    I looks that the view engine has problems compiling strongly typed base class in Inherit attribute. I had the same issue and updating the "pages" section of Web.Config to this helped:

     <pages
            validateRequest="false"
            pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
            pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
            userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <controls>
              <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
            </controls>
            <!-- rest of your pages section -->
    </pages>
    
    0 讨论(0)
提交回复
热议问题