zoukankan      html  css  js  c++  java
  • 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 }
         );
    }

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

    image

    解决方法:

    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://www.matlus.com/rest-apis-put-and-delete-cause-http-error-404/

    欢迎大家扫描下面二维码成为我的客户,为你服务和上云

  • 相关阅读:
    读取assets下的文件
    ViewPager的图片轮播
    ImageLoader的用法
    qpp的客户端
    服务器
    webview的使用
    AsyncTask方法
    HttpClientDopost方法
    通过 httpclientget 方法 向服务器中请求数据
    viewpager滑动button按钮选项卡跟着变动颜色
  • 原文地址:https://www.cnblogs.com/shanyou/p/2458577.html
Copyright © 2011-2022 走看看