Dot Character '.' in MVC Web API 2 for Request Such as API/People/Staff.45287

Dot character '.' in MVC Web API 2 for request such as api/people/STAFF.45287

Following setting in your web.config file should fix your issue:

<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />

How to support dots in WebApi2 urls for a pool running in Classic mode

Try this to set the correct handler for 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>

MVC Web API: dot in URL parameter value

If the value being passed into the URL is a search term that can be entered by the user, I wouldn't configure my routing system to handle these values because they are unpredictable.

You should encode the string and pass it through the query string or post it and bind it to an object in WebAPI.

In terms opening the door to hell I think that you should consider the points raised in this question. If you have to set something like relaxedUrlToFileSystemMapping which is something that appears to relax some of the default security systems of ASP.NET MVC I'd tend to lean towards a solution that doesn't rely on a change like this.

Web Api with & causing an error

The WebAPIConfig had constraints that was not including &. Included modified my regex expression to accept the character.



Related Topics



Leave a reply



Submit