要求
平台: Windows 2000, Windows XP Professional, Windows Server 2003 系列
获取当前请求的原始 URL。
[Visual Basic] Public ReadOnly Property RawUrl As String
[C#] public string RawUrl {get;}
[C++] public: __property String* get_RawUrl();
[JScript] public function get RawUrl() : String;
属性值
当前请求的原始 URL。
备注
原始 URL 定义为 URL 中域信息之后的部分。在 URL 字符串 http://www.contoso.com/articles/recent.aspx 中,原始 URL 为/articles/recent.aspx。原始 URL 包括查询字符串(如果存在)。
示例
[Visual Basic, C#, JScript] 下面的示例将当前请求的原始 URL 字符串分配给一个字符串变量。
[Visual Basic]
Dim MyUrl As String
MyUrl = Request.RawUrl
[C#]
String MyUrl = Request.RawUrl;
[JScript]
var myUrl : String = Request.RawUrl
[C++] 没有可用于 C++ 的示例。若要查看 Visual Basic、C# 或 JScript 示例,请单击页左上角的“语言筛选器”按钮
要求
平台: Windows 2000, Windows XP Professional, Windows Server 2003 系列
获取 HTTP 查询字符串变量集合。
[Visual Basic] Public ReadOnly Property QueryString As NameValueCollection
[C#] public NameValueCollection QueryString {get;}
[C++] public: __property NameValueCollection* get_QueryString();
[JScript] public function get QueryString() : NameValueCollection;
属性值
包含由客户端发送的查询字符串变量集合的 NameValueCollection。
示例
[Visual Basic, C#, JScript] 下面的示例接受来自客户端窗体(具有 GET 方法特性)的查询字符串,并写出窗体上每个命名输入元素的名称和值。此代码放置在由窗体的 ACTION 特性引用的 ASP.NET 页上。
[Visual Basic]
Dim loop1, loop2 As Integer
Dim arr1(), arr2() As String
Dim coll As NameValueCollection
' Load Form variables into NameValueCollection variable.
coll=Request.QueryString
' Get names of all keys into a string array.
arr1 = coll.AllKeys
For loop1 = 0 To arr1.GetUpperBound(0)
Response.Write("Key: " & Server.HtmlEncode(arr1(loop1)) & "<br>")
' Get all values under this key.
arr2 = coll.GetValues(loop1)
For loop2 = 0 To arr2.GetUpperBound(0)
Response.Write("Value " & CStr(loop2) & ": " & Server.HtmlEncode(arr2(loop2)) & "<br><br>")
Next loop2
Next loop1
[C#]
int loop1, loop2;
// Load NameValueCollection object.
NameValueCollection coll=Request.QueryString;
// Get names of all keys into a string array.
String[] arr1 = coll.AllKeys;
for (loop1 = 0; loop1 < arr1.Length; loop1++)
{
Response.Write("Key: " + Server.HtmlEncode(arr1[loop1]) + "<br>");
String[] arr2 = coll.GetValues(arr1[loop1]);
for (loop2 = 0; loop2 < arr2.Length; loop2++)
{
Response.Write("Value " + loop2 + ": " + Server.HtmlEncode(arr2[loop2]) + "<br>");
}
}
[JScript]
var arr1, arr2 : String[]
var coll : NameValueCollection
coll=Request.QueryString // Load Form variables into NameValueCollection variable.
arr1 = coll.AllKeys // Get names of all keys into a string array.
for(var i=0; i < arr1.Length; i++){
Response.Write("Key: " + Server.HtmlEncode(arr1[i]) + "<br>")
arr2 = coll.GetValues(i) // Get all values under this key.
for(var j=0; j < arr2.Length; j++){
Response.Write("Value " + j + ": " + Server.HtmlEncode(arr2[j]) + "<br><br>")
}
}
[C++] 没有可用于 C++ 的示例。若要查看 Visual Basic、C# 或 JScript 示例,请单击页左上角的“语言筛选器”按钮