好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

ASP.NET 4.0 URL Routing HTTP Error 404.0 Not Foun

ASP.NET 4.0 URL Routing HTTP Error 404.0 Not Found

在ASP.NET Web API项目中的路由注册代码如下:

public static void RegisterRoutes(RouteCollection routes) 

     routes.MapHttpRoute( 
         name: "DefaultApi", 
         routeTemplate: "api/{controller}/{filename}", 
         defaults: new { filename = RouteParameter.Optional } 
     ); 
}

当访问地址突然出现了如下错误:

解决方法:

1、确认启用了IIS的 HTTP Redirection

2、在web.config中启用asp.net 4.0 routing:

  <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"> 
      <remove name="UrlRoutingModule"/> 
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
      <remove name="WebDAVModule" /> </modules> 
    <handlers> 
      <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, 
Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a"/> 
      <remove name="WebDAV" /> 
    </handlers>  
  </system.webServer>

http://HdhCmsTestmatlus测试数据/rest-apis-put-and-delete-cause-http-error-404/

作者:  自由、创新、研究、探索……
出处: http://shanyou.cnblogs测试数据/
版权:本文版权归作者和博客园共有
转载:欢迎转载,为了保存作者的创作热情,请按要求【转载】,谢谢
要求:未经作者同意,必须保留此段声明;必须在文章中给出原文连接;否则必究法律责任 

分类:  ASP.NET MVC  ,  ASP.NET Web API

 

绿色通道: 好文要顶 已关注 收藏该文 与我联系  

作者: Leo_wl

    

出处: http://HdhCmsTestcnblogs测试数据/Leo_wl/

    

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

版权信息

查看更多关于ASP.NET 4.0 URL Routing HTTP Error 404.0 Not Foun的详细内容...

  阅读:43次