0

For example we want to edit a person and his URL is like

 person/id

but what if the value of that ID is something like "/34555P3"

  • possible duplicate of [ASP.NET MVC: URLs with slash in parameter?](http://stackoverflow.com/questions/6328713/asp-net-mvc-urls-with-slash-in-parameter) – CodeCaster Jul 11 '14 at 12:41

1 Answers1

3

Then it should be URL-encoded:

person/%2F34555P3

Since the type of the id in the routing/actions would clearly need to be a string, it will automatically be URL-decoded by the framework when determining its value. In most cases the framework will automatically URL-encode it for you when you use it as a route value in things like Html.ActionLink() or Url.Action(). Anywhere that you use the value manually you may need to encode it manually.

David
  • 208,112
  • 36
  • 198
  • 279
  • even if we have used Attributed Routing, still it should be smart enough to URL-encode it? –  Jul 11 '14 at 12:48
  • @DevWannaBe: It should, yes. The mechanism for determining the route is separate form the mechanism for encoding/decoding URL values. It would only break the route if you manually built the URL without encoding. – David Jul 11 '14 at 12:49