Reputation: 5933
http://myhost/MyController/DoSomething/Anything%252fAnything
is a bad request
http://myhost/MyController/DoSomething/Anything%2fAnything
is the same as http://myhost/MyController/DoSomething/Anything/Anything
What URL sends the string "Anything/Anything"
to my controller?
How to make Html.ActionLink
to generate that URL?
EDIT: It should be able to handle "Anything/Anything/Anything/Anything....../Anything"
also
I'm using MVC 3.
Upvotes: 2
Views: 729
Reputation: 3191
If you want to define a route that defines variable lenght routes, you can use this kind of definition:
routes.MapRoute("MyRoute", "{controller}/{action}/{id}/{*catchall}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional });
Put it before others route definitions in your global.asax.cs
Upvotes: 2
Reputation: 49104
The routing machinery wants to handle the slashes. So add a routing rule such as
url = [controller]/[action]/[id1]/[id2]
See post
Or use urls such as
http://myhost/MyController/DoSomething/Anything?id2=Anything
It may be possible to handle as a default--but in that case, the rules for the other routes will have to explicitly NOT match your controller/action name. Otherwise a prior rule will apply.
It could also be that the entire url is available from a system var. Is your controller being called at all?
Upvotes: 0