Mat*_*att 17 asp.net-mvc partial-views .net-3.5 strongly-typed-view
我正在尝试使用Html.RenderPartial()呈现带有"MVC View User Control"的强类型视图.我的ascx文件的顶部如下所示:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.Collections.IEnumerable<string>>" %>
Run Code Online (Sandbox Code Playgroud)
目前,此页面上没有其他内容.
当我执行应用程序并加载呈现此控件的页面时,我收到以下错误:
Could not load type 'System.Web.Mvc.ViewUserControl<System.Collections.IEnumerable<string>>'.
Run Code Online (Sandbox Code Playgroud)
那么,我简化了它:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<String>" %>
Run Code Online (Sandbox Code Playgroud)
然后,以防万一需要完全合格:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.String>" %>
Run Code Online (Sandbox Code Playgroud)
每次我得到相同的错误(替换类型).我在这做错了什么?我在.NET 3.5上使用ASP.NET MVC 1.0 RTM.
Mat*_*att 27
我搞定了.我按照http://www.codewrecks.com/blog/index.php/2009/04/05/could-not-load-type-systemwebmvcviewpage/上的说明操作,这对我来说很有用.我应该注意到,我还是从2010年3月17日开始升级到ASP.NET MVC 2.0 RC.在我按照该页面上的说明操作之前,问题仍然存在.我不确定一个新的MVC项目现在是否适合你.
如果引用的页面消失,解决方案是将Web.config添加到我的Views目录,并将其放入其中:
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*"
type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
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">
<controls>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
</handlers>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我还要注意,对于MVC 2.0,您需要更新配置中的版本#.
归档时间: |
|
查看次数: |
6548 次 |
最近记录: |