views:

505

answers:

1

I have seen the error "The ';' character, hexadecimal value 0x3B, cannot be included in a name." in my log files for an ASP.NET Web App. The url that's logged looks something like this:

mypage.aspx?paramone=one+two&paramtwo=zero+1

So my first question is what type of system/browser is encoding the original query string? (This happens rarely)

I've tried to address this problem with the following snippet of code in the Page_Load() event:

string rawUrl = Request.RawUrl;
if (rawUrl.Contains(amp))
{
    rawUrl = rawUrl.Replace("&", "&");
    Server.Transfer(rawUrl, false);
    return;
}

However when it transfers back to this page the & is back in the query string. So I'm guessing that the .Transfer() function encodes the first param.

Suggestions about solving this problem?

+1  A: 
  1. Your web server should be able to log the "user agent" field from the HTTP Request, which should enable you to identify the culprit.

  2. Don't fix it - there's a very well defined set of legal syntaxes for URI parameters, and this ain't one of them.

Alnitak
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
tamberg
I appreciate the sentiment in not fixing it, however, wouldn't you rather redirect a user to the correct resource (301 permanent redirect) if they are requesting it incorrectly?
Guy