在HttpRequest中的RawUrl和QueryString之间,使用特定语言的URL参数对URL参数进行UTF-8编码的结果不同

时间:2018-08-09 10:15:55

标签: c# utf-8 httprequest request.querystring rawurl

更新-8月31日

string test = "ö";
string unicode1 = HttpUtility.UrlEncode(test, Encoding.Unicode);
string unicode2 = HttpUtility.UrlEncodeUnicode(test);
Console.WriteLine("Result of unicode1: " + unicode1);
Console.WriteLine("Result of unicode2: " + unicode2);

我们可以看到不同的结果。现在的情况是,当我使用UrlEncode的URL中的参数发布数据时,当浏览器获取资源时,它将返回unicode2。

更新-8月30日 please click the link to see the tracing httprequest 奇怪的是QueryString中的参数“ nm”的值变得不同,其原始字符串为“ööö”,因此我们可以在Url中看到它,通过UTF-8编码后,它变成了“%c3%b6%c3%一般情况下,应保持RawUrl和QueryString之间的编码结果相同。有人知道原因吗?

我遇到了一个问题,即单击按钮后URL引用程序将变为null。 我填写了文本“öööööööööö”,您可以看到c#和IE之间的不同编码。

the url encoded by c#, it was captured by Fiddler

the url encoded by IE, it was displayed in IE status bar

UTF8编码的结果:“%c3%b6%c3%b6%c3%b6%c3%b6%c3%b6%c3%b6%c3%b6%c3%b6”

通过IE编码的结果:“%u00f6%u00f6%u00f6%u00f6%u00f6%u00f6%u00f6%u00f6”

有人知道它如何发生并伸出援手吗?

0 个答案:

没有答案