asp.net – 在IIS中将WebAPI添加为子/嵌套应用程序
发布时间:2020-05-24 15:26:31 所属栏目:asp.Net 来源:互联网
导读:重新创建此问题的步骤: 在IIS内部创建一个新的.net 4网站(此处称为父网站). 将测试图像放在本网站的文件夹中,然后观察即可 在浏览器中成功申请 在指向WebAPI 2项目的父项下添加新的虚拟目录或应用程序 尝试使用www.path-to-parent-site.com/api/something/or
|
重新创建此问题的步骤: >在IIS内部创建一个新的.net 4网站(此处称为父网站). 我收到以下错误: 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中的新网站,它可以很好地工作;它只有在嵌套为子(虚拟目录或应用程序具有相同问题)时才会发生这种情况. 谢谢 解决方法WebApi不应该托管在虚拟目录上,如果您想这样做,您需要使路由模式动态化并从虚拟目录加载第一部分.var virtualDirectory = request.ApplicationPath;
routes.MapHttpRoute(
name: "API Default",routeTemplate: virtualDirectory + "/api/{controller}/{id}",defaults: new {
id = RouteParameter.Optional
}
); (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp-classic – 如何在经典ASP中遍历集合?
- asp.net – WebForm_DoPostBackWithOptions没有使用chrome定
- asp.net – 将初始空行插入到选择列表MVC LINQ SQL中
- asp.net-mvc-3 – 如何使用ModelMetadata单元测试modelbind
- asp.net-mvc – 如何在Kendo模板中动态设置列
- asp.net-mvc – MVC5中的Bundle.IncludeDirectory输出错误的
- asp.net-mvc – 哪个更正确:使用UpdateModel()或接收模型作
- asp.net-mvc – 使用OWIN的Google身份验证Oauth在MVC5中没有
- asp.net Xml绑定到数据控件的具体实现
- asp.net – 您如何看待Postgres和Firebird数据库?
推荐文章
站长推荐
- asp.net-mvc – 实时ASP.NET MVC Web应用程序
- 强制ASP.NET为所有用户代理生成JavaScript
- asp.net-mvc – 使用Razor在ASP.NET MVC 4中防止
- asp.net-mvc – 在视图中格式化小数
- asp.net-mvc – 如何将特定于HTTP-Request的对象
- AspNet Core在内存中使用,用于在IIS中运行时进行
- 如何在ASP.NET MVC 4和jquery中使用web api下载文
- 在文件系统中获取ASP.NET MVC站点的路径
- 实体框架 – 实体框架核心更新许多对许多
- asp.net-web-api – 密码更改时如何使OAuth令牌无
热点阅读
