Domanda

Sto tentando di creare una vista fortemente tipizzato con un "MVC View User Control" che viene eseguito il rendering utilizzando Html.RenderPartial (). La parte superiore del mio file ascx assomiglia a questo:

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

Non c'è niente altro in questa pagina, al momento.

Quando eseguo l'applicazione e caricare la pagina che rende questo controllo, ottengo il seguente errore:

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

Così, allora ho semplificato che:

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

E poi, nel caso in cui aveva bisogno di essere pienamente qualificato:

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

Ogni volta che ottengo il (tipo sostituendo) stesso errore. quello che sto facendo male qui? Sono in .NET 3.5 con ASP.NET MVC 1.0 RTM.

È stato utile?

Soluzione

ho ottenuto lavorando. Ho seguito le istruzioni da http : //www.codewrecks.com/blog/index.php/2009/04/05/could-not-load-type-systemwebmvcviewpage/ e che ha fatto il trucco per me. Vorrei sottolineare che ho anche aggiornato alla ASP.NET MVC 2.0 RC a partire dal 2010/03/17 prima. Il problema persisteva per me ancora fino a quando ho seguito le istruzioni da quella pagina. Non sono sicuro se un progetto MVC fresca fa per voi oppure no.

La soluzione, nel caso in cui la pagina di riferimento va via, è stato quello di aggiungere un Web.config al mio indice Visualizzazioni, e mettere questo in esso:

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

Vorrei anche notare che per MVC 2.0 è necessario aggiornare la versione # 's nel config.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top