1

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

asked Jan 31, 2013 at 8:49

1 Answer 1

3

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.

answered Jan 31, 2013 at 8:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.