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

前端 未结 4 1286
盖世英雄少女心
盖世英雄少女心 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: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 " %>
    <%@ Import Namespace="MyNamespace" %>
    <% var model = (MyModel)Model; %>
    
    

    <% model.MyField %>

提交回复
热议问题