2

I want to implement a routing system that admits a dot in the url. Currently I handle urls like:

mydomain/User/Details/raguilar

but if the username has a dot, then it is generated as:

mydomain/User/Details?username=r.aguilar

I tried to add the following route:

routes.MapRoute(
            name: "Users",
            url: "User/{action}/{username}",
            defaults: new { controller = "User", username = UrlParameter.Optional },
            constraints: new { username = @"\w+\.?\w+" }
        );

and all seems to be ok, but when I clicked on the url I received an error that says that the related resource is not found or something like that.

Is there some way to fix this issue?

Reynaldo Aguilar
  • 1,906
  • 1
  • 15
  • 29
  • Not sure if this helps, but check [this](http://stackoverflow.com/questions/11728846/dots-in-url-causes-404-with-asp-net-mvc-and-iis) post. And [this](http://www.codeproject.com/Questions/216044/Period-dot-in-ASP-NET-MVC-Route) on codeproject. I don't have access to VS so not able to try these out. – Nilesh Mar 11 '14 at 18:03
  • @Nilesh: Thanks, the first link helps me. I had looked for a question like that but I didn't find it. – Reynaldo Aguilar Mar 11 '14 at 18:19
  • That is great. You can answer your own question if you found the right solution. This might help someone else. – Nilesh Mar 11 '14 at 18:27

1 Answers1

0

In order to solve this problem I should add the following line to the system.webServer/handlers element:

<add  name="ApiURIs-ISAPI-Integrated-4.0" 
      path="/user/*" 
      verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" 
      type="System.Web.Handlers.TransferRequestHandler" 
      preCondition="integratedMode,runtimeVersionv4.0" />

Where user is the controller to which belong the paths that will contain the dot.

dav_i
  • 27,509
  • 17
  • 104
  • 136
Reynaldo Aguilar
  • 1,906
  • 1
  • 15
  • 29