Passing special characters in http get request

Have a webpage that is opened from another system with parameters that can contain extended ascii characters:


Open in new window

The cshtml webpage reads the parameters as usual with:

var pname = Request["pname"];
and shows it on the page with @pname

Works fine for all browsers except IE (even IE11) when pname=Günther or another name with foreign characters; ü, ø and so on.


Open in new window

results in G�nther
The webpage is using <meta charset="UTF-8" />

Why does this work in Chrome and Opera but not in IE?
Any solution? I have no control over the submitting system, som the url cannot be encoded before submit.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontyWeb Ninja at largeCommented:
try using HTMLEncode() in combination with some manual escaping of the characters of the url you pass. This article provides more details, but essentially, the code would be:

public static string HtmlEncode( string text ) {
    char[] chars = HttpUtility.HtmlEncode( text ).ToCharArray();
    StringBuilder result = new StringBuilder( text.Length + (int)( text.Length * 0.1 ) );

    foreach ( char c in chars ) {
        int value = Convert.ToInt32( c );
        if ( value > 127 )
            result.Append( c );

    return result.ToString();

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kanti PrasadCommented:
Hi Julian Hansen

Ok Thanks! I will put some notes around before I post any link.

fmsolAuthor Commented:
Thank you Big Monty,
but why isn't this a problem in Opera and Chrome? Only IE?

I can also solve it by using jQuery:

Open in new window

which returns the correct  string, but I thought it could be solved more easily with another codepage or something.
Big MontyWeb Ninja at largeCommented:
Because IE is a lot less forgiving than other browsers (older versions at least) because it doesn't always follow the same standards. Once Edge comes out, hopefully all of that goes away.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.