WebAPI route 404's when there is a trailing space in the URL

萝らか妹 提交于 2019-11-27 15:08:59
nemesv

Your issue has nothing to do with WebAPI itself but how Asp.Net handles some specific urls. And Asp.Net handles these urls in a very paranoid way, so you need to tell it to relax.

Add this line to your web.config under system.web:

<httpRuntime relaxedUrlToFileSystemMapping="true" />

You can read more about this topic:

Also on SO:

Add this to handlers

      <add name="ExtensionlessUrlHandler-Integrated-4.0-ForApi"
     path="api/*"
     verb="*"
     type="System.Web.Handlers.TransferRequestHandler"
     preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!