开发者

ASP.NET / VB.NET - What is the equivalent of $_REQUEST of PHP in ASP.NET?

开发者 https://www.devze.com 2023-03-26 02:37 出处:网络
I\'m 开发者_运维知识库just wondering, is there a way to get the GET parameters and POST parameters in just one function or Collection in ASP.NET? Like using $_REQUEST in PHP? I\'m using VB.NET.Request

I'm 开发者_运维知识库just wondering, is there a way to get the GET parameters and POST parameters in just one function or Collection in ASP.NET? Like using $_REQUEST in PHP? I'm using VB.NET.


Request["VariableName"] (in C#) and Request("VariableName") (in VB) should work.

See HttpRequest.Item indexer:

Name-value pairs are returned in the following order:

  1. Query-string parameters.
  2. Form fields.
  3. Cookies.
  4. Server variables.

If the specified key is not found, then null is returned.


Note:

Request["xyz"] gets it from cookies, querystring, form, or server variables

Request.Parameters["xyz"] does the same

Request.QueryString["xyz"] is just the querystring

Request.Form["xyz"] is just the form


Sure is: Request.QueryString for GET, Request.Form for POST. You can specify a name to extract, i.e. Request.QueryString("id"), to get the "id" from the URL.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号