My.Response 物件

可取得與 Page 相關聯的 HttpResponse 物件。 此物件可讓您將 HTTP 回應資料傳送給用戶端,並包含該回應的相關資訊。

備註

My.Response 物件包括與該頁面相關聯的 HttpResponse 物件。

My.Response 物件僅適用 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>

另請參閱