asp.net-mvc – 如何在经典模式下运行的池中支持WebApi2 URL中的点

我需要在URL中支持点,例如http:// myserver / product / find?name = the.product.name,用于在经典模式下运行的池.

这里有很多问题和答案:

> Dot character ‘.’ in MVC Web API 2 for request such as api/people/STAFF.45287
> Dots in URL causes 404 with ASP.NET mvc and IIS

但它们都不适用于在经典模式下运行的应用程序池.

我试过了:

>< httpRuntime relaxedUrlToFileSystemMapping =“true”> …
>< modules runAllManagedModulesForAllRequests =“true”> …
>< handlers>< add name =“ApiURIs-ISAPI-Integrated-4.0”path =“/ people / *”verb =“…”type =“System.Web.Handlers.ransferRequestHandler”preCondition =“integratedMode, runtimeVersionv4.0“/>
>< modules> …< add name =“UrlRoutingModule-4.0”type =“System.Web.Routing.UrlRoutingModule”/>

他们都没有在Classic中工作.

唯一不可接受的解决方法似乎是添加尾随/如果点在URL中,或者如果点在params中则添加额外参数:

> http://myserver/product/find.all/
> http:// myserver / product / find?name = the.product.name& useless = 1

我无法切换到集成.

最佳答案 尝试此操作为classicMode设置正确的处理程序

  <handlers>
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit"/>
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" 
      path="*" 
      verb="GET,HEAD,POST,DEBUG,DELETE,OPTIONS" 
      modules="IsapiModule" 
      scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" 
      preCondition="classicMode,runtimeVersionv4.0,bitness32" 
      responseBufferLimit="0" />

    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"/>
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" 
      path="*" 
      verb="GET,HEAD,POST,DEBUG,DELETE,OPTIONS" 
      modules="IsapiModule" 
      scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" 
      preCondition="classicMode,runtimeVersionv4.0,bitness64" 
      responseBufferLimit="0" />
  </handlers>
点赞