Reputation: 2273
I have the following routing path defined in global.asax to handle two parameters in the url:
routes.MapRoute(
"Default", // Route name
"{page}/{th}", // URL with parameters
new { controller = "Home", action = "Index", page = UrlParameter.Optional, th = UrlParameter.Optional } // Parameter defaults
);
The first parameter is a URL of another website, i.e. www.othersite.com/about/.
Even if I encode the slashes to %2f it fails to route the URL correctly. I want to use something like this:
http://{mywebsite}/www.othersite.net%2fabout%2f/{parameter2}
I do not want to use Base64 encoding as I want the URL to be readable as above.
I'm using MVC 3.
Thanks
Upvotes: 1
Views: 3701
Reputation: 1038710
Take a look at the following blog post
from Scott Hanselman where he explains some possible workarounds. But the conclusion is:
After ALL this effort to get crazy stuff in the Request Path, it's worth mentioning that simply keeping the values as a part of the Query String (remember WAY back at the beginning of this post?) is easier, cleaner, more flexible, and more secure.
So basically it would be better to use an url encoded query string parameter for this instead of trying to fight against IIS in a battle that you will probably lose.
Upvotes: 3