HttpUtility.ParseQueryString无需解码特殊字符 [英] HttpUtility.ParseQueryString without decoding special characters

查看:220
本文介绍了HttpUtility.ParseQueryString无需解码特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Uri uri = new Uri(redirectionUrl);
NameValueCollection col = HttpUtility.ParseQueryString(uri.Query)

uri.Query 已去codeD - 那么有没有什么办法可以prevent ParseQueryString 再进行解码呢?

uri.Query is already decoded - so is there any way I can prevent ParseQueryString decoding it again?

除此之外 - 有另一种方法来检索从URI的名字的收藏价值,而不修改任何组件

Apart from that - is there another method to retrieve a name value collection from a Uri without modifying any components?

推荐答案

编码 uri.Query 将它传递给前 ParseQueryString 是涉及到我头​​上的第一件事。

Encoding the uri.Query before passing it to ParseQueryString is the first thing that comes to my head.

更新

刚检查了 ParseQueryString 方法与反射器:它假定查询字符串连接codeD,你不能用它做什么?长号。所以,我认为你需要手动解析它(有很多准备使用的算法在网络上)。

Just checked the ParseQueryString method with Reflector: it assumes that the query string is encoded and you can't do anything with it... Bummer. So I think you need to parse it manually (there are plenty of ready-to-use algorithms on the Web).

另外,您可以连接code你的查询字符串正确(考虑到变量名和所有的特殊字符),它传递给 ParseQueryString 方法之前。

Alternatively you could encode your query string properly (taking into account variable names and all special characters) before passing it to ParseQueryString method.

- 帕维

这篇关于HttpUtility.ParseQueryString无需解码特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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