在URLRewriter查询字符串&符号 [英] Ampersands in URLRewriter Query Strings

查看:168
本文介绍了在URLRewriter查询字符串&符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含符号查询字符串参数值。例如,对于该参数的有效值可以是:

I have a query string parameter value that contains an ampersand. For example, a valid value for the parameter may be:

a & b

当我生成一个包含该参数的URL,我使用System.Web.HTTPUtility.UrlEn code(),使每个元素URL友好。这是(正确)给了我一个网址,如:

When I generate the URL that contains the parameter, I'm using System.Web.HTTPUtility.UrlEncode() to make each element URL-friendly. It's (correctly) giving me a URL like:

http://example.com/foo?bar=a+%26b

问题是,ASP.NET的Request对象是除preting的(EN codeD)符号作为查询字符串参数分隔符,并因此分裂我的价值分为两部分(第一个具有栏作为参数名,第二个有一个空的名字)

The problem is that ASP.NET's Request object is interpreting the (encoded) ampersand as a Query String parameter delimiter, and is thus splitting my value into 2 parts (the first has "bar" as the parameter name; the second has a null name).

看来,ASP.NET是URL解码第一的URL,然后使用解析查询字符串的时候。

It appears that ASP.NET is URL-decoding the URL first and then using that when parsing the query string.

什么是解决这个的最佳方式?

What's the best way to work around this?


更新:这个问题在铰链上 URLRewriter (第三方插件),而不是ASP.NET本身。我已经改变了标题,以反映这一点,但我会离开的问题文本的其余部分按原样,直到我了解更多的问题。

UPDATE: The problem hinges on URLRewriter (a third-party plugin) and not ASP.NET itself. I've changed the title to reflect this, but I'll leave the rest of the question text as-is until I find out more about the problem.

推荐答案

切换到 UrlRewritingNet。 UrlRewrite 做的不可以帮助,因为它显然具有相同的错误。我想它可能有一些毕竟做ASP.NET。

Switching to UrlRewritingNet.UrlRewrite did not help, as it apparently has the same bug. I'm thinking it might have something to do with ASP.NET after all.

这篇关于在URLRewriter查询字符串&符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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