C# - How to list out variable names and values posted to ASPX page

后端 未结 8 2319
春和景丽
春和景丽 2021-02-13 10:11

I am dynamicaly generating a HTML form that is being submitted to a .aspx webpage. How do I determine in the resulting page what variable names were submitted and what the value

8条回答
  •  独厮守ぢ
    2021-02-13 10:18

    Each of Request.Cookies, Request.Form, Request.QueryString and Request.ServerVariables is a NameValueCollection or similar. You can ask each of those for its keys, and proceed from there.

    foreach (string key in Request.QueryString.Keys)
    {
        string value = Request.QueryString[key];
        // etc
    }
    

    Quite which collections you need will depend on the purpose of this - if it's just for diagnostics, I'd be tempted to dump them all out.

提交回复
热议问题