在 IIS 7 中,我使用 Nancy 项目创建了一个网站。然后,我使用 alias 向站点添加了一个 MVC 2 应用程序api
。我能够完美地访问 Nancy 项目中定义的路线。但是,当我访问 时/api
,出现以下错误:
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
似乎 MVC 2 应用程序正在尝试使用 NancyHttpRequestHandler 来处理请求。我这样说是因为 Nancy 应用程序中未定义的路由会显示 404 页面。
我尝试了几件事:
对于
Web.config
MVC 2 应用程序,我在<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>
对于
Web.config
Nancy 应用程序,我在<system.web/>
块中添加了以下内容:<httpHandlers> <add verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" /> <remove verb="*" path="api/*" /> </httpHandlers>
我还尝试在两个应用程序中玩弄
<system.webServer/>
和块中的设置。<system.serviceModel/>
当 MVC 2 应用程序嵌入到 IIS 7 的 Nancy 站点中时,如何让其正常运行?任何指导将不胜感激。