Re: Request.QueryString Collection Doesn't Get Umlauts

Tech-Archive recommends: Fix windows errors by optimizing your registry



Axel Dahmen wrote:

> Hi,
>
> I've created an aspx page taking a query string argument as parameter.
> Although I've correctly escaped umlauts in the query string, they do
> not appear in the QueryString collection. If I give:
> http://myComp/myPage.aspx?q=G%FCnther
>
> Request.QueryString[0] yields "Gnther" instead of "Günther".
>
> What's happening?

%FC is ü in ISO-8859-1 (or -15), but ASP.NET is using UTF-8 by default
to decode request parameters (including the query string). That leaves
you with the following choices:

1. Change your application's <globalization/> element in web.config to
use ISO-8859-1 as requestEncoding (and in this case preferably
responseEncoding as well).

2. If you want to change the request encoding through code, set in it
your HttpApplication's (e.g. global.asax) Application_BeginRequest
callback:

protected void Application_BeginRequest(Object sender, EventArgs e)
{
//This will override the <globalization/> entry with ISO-8859-1
Request.ContentEncoding = Encoding.GetEncoding(28591);
}

3. Make sure the client is using UTF-8 when encoding request
parameters. How to achieve that depends on your web client. Since
you're using a Web Form, it's most likely that the browser uses the
wrong encoding. Did you add some META tag to your Web Form, or is your
browser configured to use ISO-8859-1 exlcusively?

Cheers,
--
http://www.joergjooss.de
mailto:news-reply@xxxxxxxxxxxxx
.



Relevant Pages

  • Re: Request.QueryString Collection Doesnt Get Umlauts
    ... the address bar of my browser. ... Now I've created a simply GET form and set the encoding to UTF-8 manually. ... >> I've created an aspx page taking a query string argument as parameter. ... If you want to change the request encoding through code, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: click once command line parameters how to ?
    ... I probably know as much about web dev as you do. ... Another thing to be aware of is if you are using vs2008, anyone running xp with sp-1 will have problems if you run the app with a different query string after the 1st time -- there is a reported bug for this. ... I have found several references that tell me these> applications ... Do I need to write an application to send the http request? ...
    (microsoft.public.dotnet.framework)
  • RE: Mixing GET and POST generates inconsistence in URLS...
    ... an even to "Load a Page". ... > cause post back and so on: it's a classic POST web form. ... > there's a navigation control that changes the query string. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Redirect
    ... tells the browser to request a different page. ... redirect forces a new page request, the browser has to make two round trips ... The user could then select different values as which cases I am re-directing back to the same page with a response.redirect with the new query string. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Single Sign On in Web Application & WinForm Application
    ... I take this login ... The ASP.NET page reads the query string parameter, ... differently than from direct page request. ...
    (microsoft.public.dotnet.languages.vb)