views:

707

answers:

2

I use HttpUtility.UrlEncode to encode any value that is used in a route.

I already solved an issue with encoding forward slashes. The new problem I have now is with spaces. A space is encoded as + .

This works on the VS integrated Webserver, but I have an issue with it in IIS7 on Windows Server 2008. If I have the URL http://localhost/Home/About/asdas+sdasd

I get the error 404.11 - Request contains double escape sequence.

I know I can just replace the space by "%20", but I dont want to care about propper encoding myself. Is there any ready to use UrlEncoder for MVC out there?

+1  A: 

' ' encoded to %20 use HttpUtility.UrlPathEncode.

takepara
ray247
A: 

Any URL Encoding is most often designed to work on the path component of the url, the reason because different schemes have different characters in the safe list. Look for your libraries urlencoder and just use it in the path and above portion of the url.

Senthil Kumaran