Getting Umlauts from QueryString

  • Thread starter Thread starter Tomas Vera
  • Start date Start date
T

Tomas Vera

Hello All,
On my website, I have a page where the user's logon ID is passed in through
the URL.
When the user's name contain's an umlaut (and presumably other accented
letters), the query string seems to be stripping out the special
characters.

Example:
http://www.mysite.com/mypage.aspx?id=Röchling

In my code I get
string myString = Request["id"];

and myString now contains 'Rchling'

The umlaut-O letter is missing. It sits in the Raw query string, but not in
the Request.

This is only the beginning of the problem, since this is Commerce Server
application, and the next step is to retrieve the User's profile. And of
course the user's name is incorrect.

Is there some way that I can configure the page (or the entire site) so
that special characters are not stripped out in the query string? Probably
something simple, but I've not come across the answer yet this morning.

TIA,

Thanks,
-tomas
 
Tomas Vera said:
On my website, I have a page where the user's logon ID is passed in through
the URL.
When the user's name contain's an umlaut (and presumably other accented
letters), the query string seems to be stripping out the special
characters.

Example:
http://www.mysite.com/mypage.aspx?id=Röchling

In my code I get
string myString = Request["id"];

and myString now contains 'Rchling'

The umlaut-O letter is missing. It sits in the Raw query string, but not in
the Request.

This is only the beginning of the problem, since this is Commerce Server
application, and the next step is to retrieve the User's profile. And of
course the user's name is incorrect.

Is there some way that I can configure the page (or the entire site) so
that special characters are not stripped out in the query string? Probably
something simple, but I've not come across the answer yet this morning.

Using the URL for parameters is inherently problematic as the character
set (and encoding) used for the URL isn't well-specified in HTTP (as
far as I could tell last time I looked, anyway). If you use a POST
request instead, it should be much more robust.
 
Doh!!

The link to this page is actually in an e-mail sent to the end user to
confirm their email address.

Would using "Server.UrlEncode(userNameWithUmlaut)" allow me to construct a
link that is more acceptable?

Thanks,
-tomas



Tomas Vera said:
On my website, I have a page where the user's logon ID is passed in through
the URL.
When the user's name contain's an umlaut (and presumably other accented
letters), the query string seems to be stripping out the special
characters.

Example:
http://www.mysite.com/mypage.aspx?id=Röchling

In my code I get
string myString = Request["id"];

and myString now contains 'Rchling'

The umlaut-O letter is missing. It sits in the Raw query string, but not in
the Request.

This is only the beginning of the problem, since this is Commerce Server
application, and the next step is to retrieve the User's profile. And of
course the user's name is incorrect.

Is there some way that I can configure the page (or the entire site) so
that special characters are not stripped out in the query string? Probably
something simple, but I've not come across the answer yet this morning.

Using the URL for parameters is inherently problematic as the character
set (and encoding) used for the URL isn't well-specified in HTTP (as
far as I could tell last time I looked, anyway). If you use a POST
request instead, it should be much more robust.
 
To answer my own question: Yes, it works.

If I use Server.UrlEncode(username) to create the email link to the
activation page, the link seems to work OK.

I should probably use this all over the place where I create links and use
the Reponse.Redirect call.

-tomas

Doh!!

The link to this page is actually in an e-mail sent to the end user to
confirm their email address.

Would using "Server.UrlEncode(userNameWithUmlaut)" allow me to construct a
link that is more acceptable?

Thanks,
-tomas



Tomas Vera said:
On my website, I have a page where the user's logon ID is passed in through
the URL.
When the user's name contain's an umlaut (and presumably other accented
letters), the query string seems to be stripping out the special
characters.

Example:
http://www.mysite.com/mypage.aspx?id=Röchling

In my code I get
string myString = Request["id"];

and myString now contains 'Rchling'

The umlaut-O letter is missing. It sits in the Raw query string, but not in
the Request.

This is only the beginning of the problem, since this is Commerce Server
application, and the next step is to retrieve the User's profile. And of
course the user's name is incorrect.

Is there some way that I can configure the page (or the entire site) so
that special characters are not stripped out in the query string? Probably
something simple, but I've not come across the answer yet this morning.

Using the URL for parameters is inherently problematic as the character
set (and encoding) used for the URL isn't well-specified in HTTP (as
far as I could tell last time I looked, anyway). If you use a POST
request instead, it should be much more robust.
 
Tomas Vera said:
To answer my own question: Yes, it works.

If I use Server.UrlEncode(username) to create the email link to the
activation page, the link seems to work OK.

I should probably use this all over the place where I create links and use
the Reponse.Redirect call.

It's still not particularly good though - UrlEncode will have to assume
an encoding of some description.

If it's the only option you've got, it's worth using - but wherever you
can avoid it, do.
 
Back
Top