[英]How to get all the parameters names of a Get Request (from query string)?
I have an asp.net application and I get each parameter individually.我有一个 asp.net 应用程序,我单独获取每个参数。 Like this.
像这样。
HttpContext.Current.Request["bet_transaction_id"]
Because the paraemeter list in the get request is unpredictable, I need a way to get them and their associated values dynamically.因为 get 请求中的参数列表是不可预测的,所以我需要一种方法来动态获取它们及其关联值。 How can I achieve so?
我怎样才能做到这一点?
UPDATE - Working solution.更新 - 工作解决方案。
Dictionary<string, string> queryParams = new Dictionary<string, string>();
foreach (var queryKey in HttpContext.Current.Request.QueryString)
{
queryParams.Add(queryKey.ToString(), HttpContext.Current.Request.QueryString[queryKey.ToString()]);
}
Dictionary<string,string> queryParams= new Dictionary<string, string>();
foreach (var queryKey in Request.Query.Keys)
{
queryParams.Add(queryKey, Request.Query[queryKey]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.