简体   繁体   English

ASP.NET / VB.NET-ASP.NET中PHP的$ _REQUEST等效项是什么?

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

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? 我只是想知道,是否有一种方法可以在ASP.NET的一个函数或Collection中获取GET参数和POST参数? Like using $_REQUEST in PHP? 喜欢在PHP中使用$_REQUEST吗? I'm using VB.NET. 我正在使用VB.NET。

Request["VariableName"] (in C#) and Request("VariableName") (in VB) should work. Request["VariableName"] (在C#中)和Request("VariableName") (在VB中)应该可以正常工作。

See HttpRequest.Item indexer : 参见HttpRequest.Item索引器

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. 如果找不到指定的键,则返回null

Note: 注意:

Request["xyz"] gets it from cookies, querystring, form, or server variables Request["xyz"]从Cookie,查询字符串,表单或服务器变量中获取

Request.Parameters["xyz"] does the same Request.Parameters["xyz"]执行相同的操作

Request.QueryString["xyz"] is just the querystring Request.QueryString["xyz"]只是查询字符串

Request.Form["xyz"] is just the form Request.Form["xyz"]只是表格

Sure is: Request.QueryString for GET, Request.Form for POST. 肯定的是: Request.QueryString为GET, Request.Form为POST。 You can specify a name to extract, ie Request.QueryString("id") , to get the "id" from the URL. 您可以指定要提取的名称,即Request.QueryString("id") ,以从URL中获取“ id”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM