Heidi
Heidi

Reputation: 1417

Server.Encode / decode not working in production server

I pass a vb.net query string to a page with, depending on the parameter, a spanish character on it, wich works perfectly on the development and testing servers, but not in production.

So, inside the query string I encode the name like this:

Server.UrlEncode(name)

And even before it gets to load, the server throws a "500 Internal Server Error" with this url:

http://website/Dir/Page.aspx?num=CEJMEJINMFCEGICCEH&name=Jose+Bonse%c3%b1or+Del+Rosario

when I replace the %c3%b1 for any other normal letter, it works (%c3%b1 is an "ñ")

Again, its works just fine on the other servers, except on production, I dont even know where to start looking..

Upvotes: 1

Views: 617

Answers (2)

Josh Stodola
Josh Stodola

Reputation: 82513

The HttpServerUtility class (which "Server" is an instance of in the Page base class) uses ASCII by default to decode and encode URL parameters. ASCII, of course, is not vast enough to handle other localizations. To force Unicode, try using UrlEncodeUnicode function of the HttpUtility class instead...

HttpUtility.UrlEncodeUnicode(name)

Upvotes: 3

Mark Brittingham
Mark Brittingham

Reputation: 28875

There are two things that pop to mind although I cannot say that I've actually tested either in this specific case (request string encoding).

First, how is your page encoded? That is, do you indicate the character sets used?

Second, how is the server computer configured re: localization? I'd compare the "Regional and Language Options" in the Control Panel on the three computers.

Finally (Ok, that's three) there are localization options in Web.Config. As is often true, CodeProject has a great article on the subject.

Good luck!

Upvotes: 1

Related Questions