I have a variable
我有一个变量
string rawURL = HttpContext.Current.Request.RawUrl;
How do I read the query string parameters for this url?
如何读取此URL的查询字符串参数?
5 个解决方案
#1
26
This is probably what you're after
这可能就是你所追求的
Uri theRealURL = new Uri(HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.RawUrl);
string yourValue= HttpUtility.ParseQueryString(theRealURL.Query).Get("yourParm");
#2
8
No need to go through the RawUrl
- the Request
object already contains a parsed version, using the Request.QueryString
property.
无需通过RawUrl - Request对象已经包含使用Request.QueryString属性的已解析版本。
This is an indexed NameValueCollection
.
这是一个索引的NameValueCollection。
#3
0
There is Params property on Request object that will let you do it easily. You don't have to parse it yourself.
Request对象上有Params属性,可以让您轻松完成。您不必自己解析它。
#4
0
Try this:
尝试这个:
string rawURL = HttpContext.Current.Request.ServerVariables["query_string"];
string rawURL = HttpContext.Current.Request.ServerVariables [“query_string”];
#5
-3
This will solve your problem.....
这将解决您的问题.....
string strReq = "";
strReq = HttpContext.Current.Request.RawUrl;
strReq = strReq.Substring(strReq.IndexOf('?') + 1);
#1
26
This is probably what you're after
这可能就是你所追求的
Uri theRealURL = new Uri(HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.RawUrl);
string yourValue= HttpUtility.ParseQueryString(theRealURL.Query).Get("yourParm");
#2
8
No need to go through the RawUrl
- the Request
object already contains a parsed version, using the Request.QueryString
property.
无需通过RawUrl - Request对象已经包含使用Request.QueryString属性的已解析版本。
This is an indexed NameValueCollection
.
这是一个索引的NameValueCollection。
#3
0
There is Params property on Request object that will let you do it easily. You don't have to parse it yourself.
Request对象上有Params属性,可以让您轻松完成。您不必自己解析它。
#4
0
Try this:
尝试这个:
string rawURL = HttpContext.Current.Request.ServerVariables["query_string"];
string rawURL = HttpContext.Current.Request.ServerVariables [“query_string”];
#5
-3
This will solve your problem.....
这将解决您的问题.....
string strReq = "";
strReq = HttpContext.Current.Request.RawUrl;
strReq = strReq.Substring(strReq.IndexOf('?') + 1);