与URL-EN codeD符号prematurely德$ C $内Request.Url CD QUERYSTRING [英] Querystring with url-encoded ampersand prematurely decoded within Request.Url

查看:145
本文介绍了与URL-EN codeD符号prematurely德$ C $内Request.Url CD QUERYSTRING的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

指定的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.

这篇关于与URL-EN codeD符号prematurely德$ C $内Request.Url CD QUERYSTRING的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆