Reputation: 3746
I am using Routing Attribute to try to send a string via url to my web Api. I have a Route defined as
[Route("Search/{searchText}")]
I am expecting a string value as searchText. It seems to be working fine but I am getting an error if there is a '.' in my parameter. For ex.
http://localhost/api/Person/Search/me is working fine,
but
http://localhost/api/Person/Search/me.me
is throwing a 404 error in my browser.
The '.' character ir working fine using conventional routing
http://localhost/api/Person?q=me.me
I am getting the error only is case of attribute routing.
I have been following this article on attribute routing for all references - http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2.
How to use attribute routing for sending '.' character as a part of a string?
Upvotes: 0
Views: 120
Reputation: 551
Try adding the following to your Web.config in the <system.WebServer><handlers>...</handlers></system.WebServer>
section:
<add name="ApiURIs-ISAPI-Integrated-4.0" path="/Search/*" type="System.Web.Handlers.TransferRequestHandler" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" preCondition="integratedMode,runtimeVersionv4.0" />
Thread I used to solve this same problem: [1]: Dots in URL causes 404 with ASP.NET mvc and IIS
Edit: If you need to do this for multiple routes, you'll probably have to do /*/*
for path.
Upvotes: 1