获得从乌里单独的查询参数 [英] Get individual query parameters from Uri

查看:142
本文介绍了获得从乌里单独的查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个URI字符串,如:<一href="http://example.com/file?a=1&b=2&c=string%20param">http://example.com/file?a=1&b=2&c=string%20param

I have a uri string like: http://example.com/file?a=1&b=2&c=string%20param

有一个现有的函数,将转换查询参数字符串转换成一本字典一样的方式ASP.NET Context.Request做的。

Is there an existing function that would convert query parameter string into a dictionary same way as ASP.NET Context.Request does it.

我正在写一个控制台应用程序,而不是一个Web服务,所以没有Context.Request解析URL我。

I'm writing a console app and not a web-service so there is no Context.Request to parse the URL for me.

我知道这是pretty的易开裂查询字符串自己,但我宁愿使用FCL功能是否存在。

I know that it's pretty easy to crack the query string myself but I'd rather use a FCL function is if exists.

推荐答案

您可以使用:

var queryString = url.Substring(url.IndexOf('?')).Split('#')[0]
System.Web.HttpUtility.ParseQueryString(queryString)

MSDN

这篇关于获得从乌里单独的查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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