Application Error Handler can not get current Unicode Url

Discussion in 'ASP .Net Web Services' started by Steve, May 1, 2005.

  1. Steve

    Steve Guest

    I am using IIS 5.1 with ASP.NET 1.1
    I cannot get the correct url in the error handler in the global.asax.
    My testing global.asax:
    <%@ Application %>
    <script language="C#" runat="server">
    public void Application_Error()
    {
    Server.ClearError();
    Response.Write(Request.RawUrl + "<br>");
    Response.Write(HttpUtility.UrlDecode("%e4%b8%80"));
    }
    </script>

    I tried url http://localhost/一.aspx
    It's supposed to be "?" (a chinese character) in the url.
    But I got /�.aspx in the Request.RawUrl.
    I checked the IIS log and it logged the correct url in the log file.
    Also HttpUtility.UrlDecode returns the correct url.

    Thanks,
    Steve
    Steve, May 1, 2005
    #1
    1. Advertising

  2. It sounds like the page might have an invalid content type. Is the page
    content type UTF-8 or UTF-16?

    ASP.NET will pick up the content type from the page when doing its decoding.
    In your case it looks like it's decoding the URL into a UTF8 string rather
    than into a unicode string so you may have to 'double decode'. Try the UTF8
    Encoder to decode the string you get back from UrlDecode.

    +++ Rick ---

    --

    Rick Strahl
    West Wind Technologies
    www.west-wind.com
    www.west-wind.com/weblog



    "Steve" <> wrote in message
    news:nP8de.257$...
    >I am using IIS 5.1 with ASP.NET 1.1
    > I cannot get the correct url in the error handler in the global.asax.
    > My testing global.asax:
    > <%@ Application %>
    > <script language="C#" runat="server">
    > public void Application_Error()
    > {
    > Server.ClearError();
    > Response.Write(Request.RawUrl + "<br>");
    > Response.Write(HttpUtility.UrlDecode("%e4%b8%80"));
    > }
    > </script>
    >
    > I tried url http://localhost/一.aspx
    > It's supposed to be "?" (a chinese character) in the url.
    > But I got /�.aspx in the Request.RawUrl.
    > I checked the IIS log and it logged the correct url in the log file.
    > Also HttpUtility.UrlDecode returns the correct url.
    >
    > Thanks,
    > Steve
    >
    >
    >
    >
    Rick Strahl [MVP], May 1, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Damian
    Replies:
    3
    Views:
    12,496
    Jim Cheshire [MSFT]
    Dec 30, 2003
  2. Sergey

    How can I get current page url ?

    Sergey, Aug 16, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    18,450
    hamedvahedi
    Sep 26, 2007
  3. Steve
    Replies:
    1
    Views:
    1,326
    Rick Strahl [MVP]
    May 1, 2005
  4. Jack
    Replies:
    3
    Views:
    597
    Tad J McClellan
    Dec 22, 2008
  5. Replies:
    1
    Views:
    287
    Thomas 'PointedEars' Lahn
    Mar 19, 2008
Loading...

Share This Page