如何从ASP.NET中的FORM获取POST和GET数据 [英] How to get POST and GET data from a FORM in ASP.NET

查看:367
本文介绍了如何从ASP.NET中的FORM获取POST和GET数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下两种情况下,我需要了解如何在asp.net中以表格形式处理获取和发布数据:

I need to get an understanding about how you can handle get and post data in a form in asp.net in these 2 situations:

You submit a form with GET method: 
action: "form.php" 
parameters: text1=test

You submit a form with POST method: 
action: "form.php?text1=sometext" 
parameters: text1=somedifferenttext

我知道这三个命令:

String val1 = Page.Request["text1"];
String val2 = Page.Request.Form["text1"];
String val3 = Page.Request.QueryString["text1"];

我想知道直接访问get和post变量的确切命令是什么?

I wonder what are the exact commands to access get and post variables directly?

推荐答案

获取变量存储在

发布变量存储在表单中:

String postText1 = Page.Request.Form["text1"];

如果您想进一步了解Get和Post变量之间的区别,建议您阅读以下问题:

If you want to know more about the difference between Get and Post variables, I'd suggest having a read of this question: When do you use POST and when do you use GET?

这篇关于如何从ASP.NET中的FORM获取POST和GET数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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