HttpRequest.QueryString HttpRequest.QueryString HttpRequest.QueryString HttpRequest.QueryString Property


获取 HTTP 查询字符串变量集合。Gets the collection of HTTP query string variables.

 property System::Collections::Specialized::NameValueCollection ^ QueryString { System::Collections::Specialized::NameValueCollection ^ get(); };
public System.Collections.Specialized.NameValueCollection QueryString { get; }
member this.QueryString : System.Collections.Specialized.NameValueCollection
Public ReadOnly Property QueryString As NameValueCollection


客户端发送的查询字符串变量。The query string variables sent by the client. 键和值是 URL 解码。Keys and values are URL-decoded.


下面的代码示例演示了两种方法来获取名为 "fullname" 的查询字符串变量的值。The following code example shows two ways to get the value of a query string variable named "fullname". 在每种情况下,如果 url为,则返回的值为 "Fadi Fakhouri", %20因为将 URL 解码为空格字符。In each case, if the URL is, then the value returned is "Fadi Fakhouri" because the %20 is URL-decoded into a space character. 如果 URL 不具有fullname查询字符串 ID,则返回的值为。 nullIf the URL doesn't have a fullname query string ID, the returned value would be null.

第一行代码仅在查询字符串中查找键 "fullname";第二行在所有 HTTP 请求集合中查找密钥 "fullname"。The first line of code looks for the key "fullname" only in the query string; the second line looks for the key "fullname" in all of the HTTP request collections. 有关第二行的详细信息,请Item[String]参阅。For more information about the second line, see Item[String].

string fullname1 = Request.QueryString["fullname"];  
string fullname2 = Request["fullname"];  
Dim fullname1 As String = Request.QueryString("fullname")  
Dim fullname2 As String = Request("fullname")