views:

123

answers:

1

I am Server.UrlEncode on some query string parameters and locally it is fine but on my server (IIS 7) it causing a Bad Request error. I am using ASP.Net MVC.

If I manually change the + to a dash - the request works fine.

This breaks:

 http://www.example.com/Glenn+Pang/234

This works:

http://www.example.com/Glenn-Pang/234

Is this a setting I am missing in IIS 7?

+1  A: 

The + symbol is also the symbol for a space when URL Encoded. Could it be your routes are set up expecting the plus, which never arrives because actually its a space? I'm not sure why this would work on your local machine, but not on the IIS box though.

Edit: An un-validated random page on the net suggests that certain symbols must be encoded unless being used for their specific purpose. I'm not sure this applies to the + as my thought is that it's special purpose is representing spaces in URLs - but I guess %20 is worth a shot if that helps in any way? (And I appreciate, + rocks for Friendly URLs way more than %20 does)

Amadiere
Yeah I knew the + was for white space, route is setup to expect a string so I would assume this would be o.k.
Slee
If you're expecting a space according to your route, then it's not this. Have you tried replacing the + with a %20, what result does that give?
Amadiere
GAH - I want nice URL's so I guess I have to craft them myself. For some reason I assumed URLEncode would create valid URL's - how silly of me
Slee
http://support.microsoft.com/kb/820129 - this is a registry setting that can be chnaged (AllowRestrictedChars) - not sure if I want to do this or not.
Slee
Sucks. I think there is something missing with regards to the +. I don't suppose the error logs on IIS provided anything useful? Sometimes they can elude to other issues, but it'll probably be the fact that the + is in part of the "file" in the URL, rather than the QueryString? (speculation comment)
Amadiere