获得一个POST变量 [英] Getting a POST variable

查看:96
本文介绍了获得一个POST变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#与ASP.NET。

I am using C# with ASP.NET.

我如何检查,如果有一个参数被收为POST变量?

How do I check if a parameter has been received as a POST variable?

我需要做不同的动作,如果该参数已经通过邮寄或发送GET

I need to do different actions if the parameter has been sent via POST or via GET.

推荐答案

使用此为获取值:

Request.QueryString["key"]

和本作POST值

Request.Form["key"]

另外,如果你不在乎它是否来自GET或POST,或<一个这将工作href=\"http://msdn.microsoft.com/en-us/library/system.web.httpcontext.items.aspx\">HttpContext.Items系列:

Request["key"]

另外一点需要注意的(如果你需要它)是可以使用查询请求的类型:

Another thing to note (if you need it) is you can check the type of request by using:

Request.RequestType

将用于访问页面的动词(通常GET或POST)。 Request.IsPostBack 通常工作检查这一点,但只有在POST请求包括隐藏字段由ASP.NET框架添加到页面上。

Which will be the verb used to access the page (usually GET or POST). Request.IsPostBack will usually work to check this, but only if the POST request includes the hidden fields added to the page by the ASP.NET framework.

这篇关于获得一个POST变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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