C# - 如何列出发布到 ASPX 页面的变量名称和值 [英] C# - How to list out variable names and values posted to ASPX page

查看:20
本文介绍了C# - 如何列出发布到 ASPX 页面的变量名称和值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在动态生成一个提交到 .aspx 网页的 HTML 表单.如何在结果页面中确定提交了哪些变量名称以及值是什么?使用:Request["VarName"].toChar();有效,但假设我知道所有变量名称.如何获取名称和值?

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?

理想情况下,该解决方案适用于 POST 和 GET 提交...

Ideally, the solution would work for both POST and GET submissions...

谢谢!

推荐答案

你是否尝试过这样的事情:

Have you tried something like this:

对于发布请求:

foreach(string key in Request.Form.Keys ) 
{
   Response.Write ( Request.Form[key] );
}  

对于获取请求:

foreach(string key in Request.QueryString.Keys ) 
{
   Response.Write ( Request.QueryString[key] );
}

这篇关于C# - 如何列出发布到 ASPX 页面的变量名称和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆