简体   繁体   English

如何获取获取请求的所有参数名称(来自查询字符串)?

[英]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.

相关问题 从Lucene查询字符串获取字段名称 - Get field names from a lucene query string 如何从 url 获取当前页面,不包括查询字符串参数 - how to get current page from url excluding query string parameters 如何从 Owin 上下文中获取查询字符串参数? - How do I get query string parameters from an Owin context? 如何在 GET 方法中验证查询字符串参数 - How to validate query string parameters in GET method 如何获取所有字符串格式参数 - How to get all string format parameters 如何从HttpGET请求查询字符串中获取特定部分 - How to get a certain part from an HttpGET request query string 从类中获取要在查询字符串中使用的 JSON 属性名称列表 - Get a list of JSON property names from a class to use in a query string 如何在Web API中获取传递给请求的所有参数 - How to get all the parameters passed to the request in web API 如何将 JSON 字符串转换为 URL 参数(GET 请求)? - How can I convert a JSON string to URL parameters (GET request)? 是否有一种从Windows Phone中的URI获取查询字符串参数的简单方法? - Is there a simple way to get query string parameters from a URI in Windows Phone?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM