且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Internet Explorer 9中URL查询字符串值的UTF-8字符编码问题

更新时间:2023-11-07 22:11:04

根据Aristos的建议,使用 HttpContext.Current.Request.RawUrl 为我的情况工作。

As suggested by Aristos, using HttpContext.Current.Request.RawUrl worked for my situation.

要从RawUrl中检索实际的查询字符串值,可以使用这样一个简单的方法:

To retrieve the actual query string value from the RawUrl, a simple method like this can be used:

private string GetQueryStringValueFromRawUrl(string queryStringKey)
{
    var currentUri = new Uri(HttpContext.Current.Request.Url.Scheme + "://" + 
        HttpContext.Current.Request.Url.Authority + 
        HttpContext.Current.Request.RawUrl);
    var queryStringCollection = HttpUtility.ParseQueryString((currentUri).Query);
    return queryStringCollection.Get(queryStringKey);
}

Re使用这种方法进行测试,在IE8和IE9中工作。 IE10中修复了错误。

Retrieving the value using this method was tested as working in IE8 and IE9. The bug is fixed in IE10.