ASP.Net 和 NameValueCollection
我有以下方法:
public object[] GetEventsByUser(DateTime start, DateTime end, string fullUrl)
fullUrl 的值为:
http://localhost:50435/page/view.aspx?si=00&us=admin&ut=smt&
当我这样做时:
NameValueCollection qscoll = HttpUtility.ParseQueryString(fullUrl);
我得到:
{http%3a%2f %2flocalhost%3a50435%2fpage%2fview.aspx%3fsi=00&us=admin&ut=smt&}
但是我需要获取这个页面的QueryString中的参数,用这个值,我无法获取“si”值,因为启动查询字符串的问号已被编码。 所以我想:“嗯...我应该尝试执行 HttpUtility.HtmlEncode()”
但是 HtmlEncode 方法返回 void:但是此方法的第二个参数将值发送到 TextWriter。但它不是 NameValueCollection。
也许解决方案很简单......但我看不到它。
I have the following method:
public object[] GetEventsByUser(DateTime start, DateTime end, string fullUrl)
The value of the fullUrl is:
http://localhost:50435/page/view.aspx?si=00&us=admin&ut=smt&
When I do:
NameValueCollection qscoll = HttpUtility.ParseQueryString(fullUrl);
I get:
{http%3a%2f%2flocalhost%3a50435%2fpage%2fview.aspx%3fsi=00&us=admin&ut=smt&}
But I need to obtain the parameters in the QueryString of this page, and with this value, I cannot obtain the "si" value, because the question mark, that starts the querystring is encoded.
So I thought: "humm... I should try to do the HttpUtility.HtmlEncode()"
However the method HtmlEncode returns void: However the second parameter of this method sends the value to a TextWriter. But it isn't the NameValueCollection.
Maybe the solution is simple... but I cannot see it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在解析之前将其修剪为仅查询字符串,如下所示:
You need to trim it down to just the querystring before parsing, like this:
你可以尝试:
You could try: