重现此问题的步骤:
- 在IIS中创建一个新的.NET 4网站(以下称为父级网站)。 将测试图像放入此网站的文件夹中,并观察您可以在浏览器中成功请求它
- 在父网站下添加一个指向WebAPI 2项目的虚拟目录或应用程序
- 尝试使用www.path-to-parent-site.com/api/something/or/other在浏览器中访问API
我收到以下错误:
System.Web.Routing.UrlRoutingModule does not implement IHttpHandlerFactory or IHttpHandler.
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.Configuration.ConfigurationErrorsException: System.Web.Routing.UrlRoutingModule does not implement IHttpHandlerFactory or IHttpHandler.
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:
[ConfigurationErrorsException: System.Web.Routing.UrlRoutingModule does not implement IHttpHandlerFactory or IHttpHandler.]
System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type) +12328272
System.Web.Configuration.HandlerFactoryCache..ctor(String type) +27
System.Web.HttpApplication.GetFactory(String type) +94
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +375
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34209
有没有什么办法可以让它工作?我在这个特定问题上找到的相关信息很少,甚至看到这个错误的人的解决方案更少。
注意:如果我将WebAPI 2项目作为IIS中的新网站添加,它就可以完美运行;只有当它作为子级嵌套(无论是虚拟目录还是应用程序)时才会出现此问题。
谢谢