Search code examples
c#asp.netasp.net-web-apiodata

WebAPI OData can't deal with dots (i.e. '.') in a parameter?


I have a basic WebAPI OData application that seems to refuse to route requests to my controller if the parameter has a '.' in it.

For example:

http://localhost.com/vroot/odata/foo('abc') <== routes correctly

http://localhost.com/vroot/odata/foo('a.bc') <== returns a 404 error

I get the same 404 error even if I replace the '.' with a %2E.

http://localhost.com/vroot/odata/foo('a%2Ebc') <== returns a 404 error

Is this a generally understood problem in WebAPI OData?

Any ideas on what might be going on (or possibly how to work around this ?)


Solution

  • Dots in request urls are interpreted differently by IIS, so try adding the following setting in web.config:

    <modules>
      <remove name="UrlRoutingModule-4.0" />
      <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
    </modules>
    

    (From here: http://www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodulesfo.html )

    Some posts related to your issue:
    Dots in URL causes 404 with ASP.NET mvc and IIS