asp.net-mvc – ASP.NET Web API无法在Azure上运行
如果Web API在localhost上运行,为什么Web API会停止在Azure网站上运行.
错误是加载资源失败:服务器响应状态为404(未找到)或您要查找的资源已被删除,名称已更改或暂时不可用.在浏览器中将URL粘贴到api时 注意: WebConfig public static void Register(HttpConfiguration config) { config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi",routeTemplate: "api/{controller}/{id}",defaults: new { id = RouteParameter.Optional } ); } RouteConfig public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Cities",url: "Cities/{id}/{name}/{action}",defaults: new { controller = "Cities",action = "Index" } ); routes.MapRoute( name: "Default",url: "{controller}/{action}/{id}",defaults: new { controller = "Home",action = "Index",id = UrlParameter.Optional } ); } Global.asax中 AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Goggling透露这是一个常见问题: HTTP 404 Page Not Found in Web Api hosted in IIS 7.5 WebAPI DELETE request return 404 error in Azure WebApi and ASP.NET 4 routing issues https://stackoverflow.com/questions/15805471/using-windows-azure-websites-with-extensionlessurlhandler Configuring IIS methods for ASP.NET Web API on Windows Azure Websites How Extensionless URLs Are Handled By ASP.NET v4 Getting 404 from WebAPI on Windows Azure Web Sites ASP.NET MVC 4 and Web API in Azure – No HTTP resource was found MVC 4.5 Web API Routing not working? UPDATE 在尝试上面链接中建议的每个方法后,我已从解决方案中删除了所有* .dll,创建了一个新的MVC Web API项目并将* .dll添加到解决方案中.构建和一切都按预期工作. 解决方法
老帖子,但你试过:
<system.webServer> <modules runAllManagedModulesForAllRequests="true" /> </system.webServer> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net – MVC 3,(razor)加载部分与验证
- asp.net – 使用内部HTML与ASP:按钮?
- asp.net-mvc – 如何在VS2012 MVC4项目中设置Ext.NET 2.0?
- asp.net – 间歇性SQL连接错误
- 样本代码/代码项目的最佳ASP.NET网站[已关闭]
- asp.net – 我的通用ActionLink在哪里?
- asp.net-mvc-3 – MVC3将基类传递给局部视图 – 提交表单只
- asp.net – 初学者指南,了解如何在Visual Studio中使用Subv
- asp.net-mvc – AJAX POST到MVC Controller显示302错误
- asp.net-mvc – 避免在业务层(MVC 3)中使用SelectList
- asp.net-mvc – 为什么在Razor中使用Html.Render
- 初识ABP vNext(9):ABP模块化开发-文件管理
- ASP.NET持续学习
- asp.net-mvc – 如何在ASP.NET MVC中添加路由到动
- asp.net-mvc – ASP.net mvc页脚的公共数据
- 如何在非ASP.NET应用程序中使用ASP.NET Cache对象
- asp.net-mvc-3 – 在ASP.NET MVC 3中覆盖/禁用授
- asp.net-web-api – Windows.Web.Http.HttpClien
- asp.net-mvc-3 – 从View中访问RouteData.Values
- asp.net – 当页面用鼠标悬停在元素上时,jQuery触