与URL-EN codeD符号prematurely德$ C $内Request.Url CD QUERYSTRING符号、codeD、URL、EN

2023-09-04 04:52:37 作者:那爱消逝在巴黎的盛夏

指定的URL /Page.aspx?a=b&title=apples+%26+pears Request.Url 属性返回 /Page.aspx?a=b&title=apples+&+pears

Given url /Page.aspx?a=b&title=apples+%26+pears, Request.Url property returns /Page.aspx?a=b&title=apples+&+pears

请注意,在第二个键 - 值对的URL恩codeD和号已经自动去codeD。 其他网址连接codeD保留字符不会被自动取消codeD。

Note that the url-encoded ampersand in the second key-value pair has been automatically decoded. Other url-encoded reserved characters aren't being automatically decoded.

时的这种行为是否正确?

Is this behaviour correct?

编辑:的问题是,Request.Url属性自动解码EN codeD和号的时候,我不希望它

The issue is that Request.Url property is automatically decoding the encoded ampersand when I don't expect it to.

答: 的String.Format({0}:// {1} {2},Request.Url.Scheme,Request.Url.Host,Sitecore的.Context.Request.RawUrl)

推荐答案

网​​址请求的属性变去codeD在一个名为 Col​​lapsePercentUFromStringInternal

Url property of the Request gets decoded in an internal method called CollapsePercentUFromStringInternal.

您可以看到在反射器。这个我认为是在默认行为反正。

You can see this in the reflector. This I assumed is the default behaviour anyway.

更新

您可以使用RawUrl属性弄个非德codeD的URL。

You can use RawUrl property to get hold of the un-decoded URL.