views:

271

answers:

3

So, if there are url encoded segments in my apps MVC url, IIS throws a BAD REQUEST 400.

e.g. http://u.lasoo.com.au/Offer/*9289--750W-Generic-ATX12V-Power-Supply-%252449dot99/6355

<--- the '*' and '%' are causing this error.

Notice that http://u.lasoo.com.au/Offer/The-Giant-Good-As-Gone-7-Day-Sale/6354 works fine.

What's the correct way to convert an arbitrary string into an accepted MVC URL segment?

UPDATE: the URl segment should resemble the original string. Base64 encoding completely transformed the string.

A: 

Have you tried UrlEncode? MSDN

chris166
+1  A: 

Instead of passing the info in the url you can pass it as a get parameter. Like this:

http://u.lasoo.com.au/Offer/?id=*9289--750W-Generic-ATX12V-Power-Supply-%252449dot99/6355
despart
+1, Awesome advice. That worked for me.
Cyril Gupta
A: 

Try a string replace to strip out or substitute symbols ":", "%", "*", "/" - any symbols illegal within a folder name. They seem to screw up everything royally and appear to be a design weakness of the URL routing system

baldrick