Reputation: 61
Its a small question on MVC3 Razor, I have a string ID like "a/b" when I am trying to call details or delete method of Controller. Getting error as system assuming "a/b" as 2 parameters but I have to pass this in one string value parameters.
--Edit
< a href="@Url.Action("Details", "Search", new {id = "a/b"})">Details </a>
My Controller/method is like Search/Details (string id)
And I want to send id = 'a/b' . but .Net assuming it as 2 parameters in URL.
Please suggest.
Upvotes: 3
Views: 21313
Reputation: 67115
It appears that forward slashes are not automatically encoded, and the reason is probably because even if they are encoded (%2f), by the time they reach the routing engine they have been decoded back to a forward slash. (Search for Robj in this post by Phil Haack (former manager on the MVC team)).
However, .NET MVC Routing w/ Url Encoding Problems poses the same problem, and it appears that the only way to solve this is to insert the encoded slash into a query string. Something like this:
< a href="@Url.Action("Details", "Search")[email protected]("a/b")">Details </a>
and then, dealing with it in your method by accessing:
Request["id"]
Upvotes: 3