共用方式為


My.Request 物件

取得所要求頁面的 HttpRequest 物件。

備註

My.Request 物件包含目前 HTTP 要求的相關資訊。

My.Request 物件僅適用於 ASP.NET 應用程式。

範例

下列範例會從 My.Request 物件取得標頭集合,並使用 My.Response 物件將其寫入 ASP.NET 頁面。

<script runat="server">
    Public Sub ShowHeaders()
        ' Load the header collection from the Request object.
        Dim coll As System.Collections.Specialized.NameValueCollection
        coll = My.Request.Headers

        ' Put the names of all keys into a string array.
        For Each key As String In coll.AllKeys
            My.Response.Write("Key: " & key & "<br>")

            ' Get all values under this key.
            For Each value As String In coll.GetValues(key)
                My.Response.Write("Value: " & _
                    Server.HtmlEncode(value) & "<br>")
            Next
        Next
    End Sub
</script>

另請參閱