C# - 如何列出发布到ASPX页面的变量名称和值 [英] C# - How to list out variable names and values posted to ASPX page
本文介绍了C# - 如何列出发布到ASPX页面的变量名称和值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我动态地生成了一个提交给.aspx网页的HTML表单。如何在结果页面中确定提交的变量名称和值是什么?使用:
请求[VarName] .toChar();
工作,但假设我知道所有的变量名称。如何获得名称和值?
理想情况下,该解决方案可用于POST和GET提交...
谢谢!
解决方案
您是否尝试过这样的事情:
发送请求:
foreach(Request.Form.Keys中的字符串键)
{
Response.Write(Request.Form [key]);
}
对于获取请求:
foreach(Request.QueryString.Keys中的字符串键)
{
Response.Write(Request.QueryString [key] );
}
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 values were? Using: Request["VarName"].toChar(); Works, but assumes that I know all of the variable names. How can I get the names and values?
Ideally, the solution would work for both POST and GET submissions...
Thank you!
解决方案
Have you tried something like this:
For post request:
foreach(string key in Request.Form.Keys )
{
Response.Write ( Request.Form[key] );
}
For a get request:
foreach(string key in Request.QueryString.Keys )
{
Response.Write ( Request.QueryString[key] );
}
这篇关于C# - 如何列出发布到ASPX页面的变量名称和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文