Pregunta

Estoy intentando crear una vista fuertemente tipado con un "MVC Control de vista del usuario" que se está representando usando Html.RenderPartial (). La parte superior de mi ascx se ve así:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.Collections.IEnumerable<string>>" %>

No hay nada más en esta página, en la actualidad.

Cuando ejecuto la aplicación y la carga de la página que hace que este control, me sale el siguiente error:

 Could not load type 'System.Web.Mvc.ViewUserControl<System.Collections.IEnumerable<string>>'.

Así que, a continuación, he simplificado que:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<String>" %>

Y luego, por si acaso tenía que ser completamente calificado:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.String>" %>

Cada vez que sale el (tipo de sustitución) mismo error. ¿Qué estoy haciendo mal aquí? Estoy en .NET 3.5 con ASP.NET MVC 1.0 RTM.

¿Fue útil?

Solución

Lo tengo trabajo. He seguido las instrucciones de http : //www.codewrecks.com/blog/index.php/2009/04/05/could-not-load-type-systemwebmvcviewpage/ y que hizo el truco para mí. Debo señalar que también he actualizado a la ASP.NET MVC 2.0 RC a partir del 3/17/2010 primero. El problema persistió por mí todavía hasta Seguí las instrucciones en esa página. No estoy seguro de si un proyecto MVC fresca lo hace por usted ahora o no.

La solución, en caso de que la página de referencia se va, era añadir un Web.config a mi directorio Vistas, y poner esto en él:

<?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>

También debo señalar que para MVC 2.0 se necesita para actualizar la versión # 's en la configuración.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top