In IIS 7, ho creato un sito Web utilizzando un progetto Nancy. Quindi, ho aggiunto un'applicazione MVC 2 al sito utilizzando l'alias api
. Sono in grado di visitare perfettamente i percorsi definiti nel progetto Nancy. Tuttavia, durante la mia visita /api
, ottengo il seguente errore:Aggiungere un'applicazione MVC 2 a un sito Nancy in IIS 7
Could not load type 'Nancy.Hosting.Aspnet.NancyHttpRequestHandler'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Could not load type 'Nancy.Hosting.Aspnet.NancyHttpRequestHandler'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Could not load type 'Nancy.Hosting.Aspnet.NancyHttpRequestHandler'.]
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +11588073
System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(String type) +47
System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type) +18
System.Web.Configuration.HandlerFactoryCache..ctor(String type) +27
System.Web.HttpApplication.GetFactory(String type) +95
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +352
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
Sembra che l'applicazione MVC 2 sta tentando di utilizzare la NancyHttpRequestHandler per elaborare la richiesta. Dico questo perché i percorsi che non sono definiti nell'applicazione Nancy visualizzano una pagina 404.
ho provato diverse cose:
Per
Web.config
dell'applicazione MVC 2, ho aggiunti il seguente al blocco<system.web/>
:<httpHandlers> <add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </httpHandlers>
Per
Web.config
di applicazione Nancy, ho aggiunto il seguente al blocco<system.web/>
:<httpHandlers> <add verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" /> <remove verb="*" path="api/*" /> </httpHandlers>
Ho anche provato a giocare con le impostazioni nei blocchi
<system.webServer/>
e<system.serviceModel/>
in entrambe le applicazioni.
Come posso ottenere il corretto funzionamento dell'applicazione MVC 2 quando è incorporato nel sito di Nancy in IIS 7? Qualsiasi suggerimento sarebbe davvero apprezzato.
Eccellente! Ho appena provato questo e funziona come un fascino. Se solo potessi convincere la mia squadra a migrare tutto il nostro lavoro MVC3 dalle ultime due settimane a Nancy. :) Grazie per l'informazione. Saluti! –