HttpCapabilitiesBase.SupportsRedirectWithCookie 屬性

定義

取得值,指出瀏覽器是否在重新導向時支援 Cookie。

public:
 virtual property bool SupportsRedirectWithCookie { bool get(); };
public virtual bool SupportsRedirectWithCookie { get; }
member this.SupportsRedirectWithCookie : bool
Public Overridable ReadOnly Property SupportsRedirectWithCookie As Boolean

屬性值

如果瀏覽器在重新導向時支援 Cookie,則為 true;否則為 false。 預設為 true

範例

下列程式碼範例示範如何判斷瀏覽器是否支援重新導向上的 Cookie。

<%@ page language="C#"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    void Page_Load(Object Sender, EventArgs e)
    {
        CheckBrowserCaps();
    }

    void CheckBrowserCaps()
    {
        String labelText = "";
        System.Web.HttpBrowserCapabilities myBrowserCaps = Request.Browser;
        if (((System.Web.Configuration.HttpCapabilitiesBase)myBrowserCaps).SupportsRedirectWithCookie)
        {
            labelText = "Browser supports cookies on redirection.";
        }
        else
        {
            labelText = "Browser does not support cookies on redirection.";
        }

        Label1.Text = labelText;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Browser Capabilities Sample</title>
</head>
<body>
    <form runat="server" id="form1">
        <div>
            Browser Capabilities:
            <p/><asp:Label ID="Label1" Runat="server" />
        </div>
    </form>
</body>
</html>
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        CheckBrowserCaps()
    End Sub

    Function CheckBrowserCaps()

        Dim labelText As String = ""
        Dim myBrowserCaps As System.Web.HttpBrowserCapabilities = Request.Browser
        If (CType(myBrowserCaps, System.Web.Configuration.HttpCapabilitiesBase)).SupportsRedirectWithCookie Then
            labelText = "Browser supports cookies on redirection."
        Else
            labelText = "Browser does not support cookies on redirection."
        End If

        Label1.Text = labelText

    End Function 'CheckBrowserCaps
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Browser Capabilities Sample</title>
</head>
<body>
    <form runat="server" id="form1">
        <div>
            Browser Capabilities:
            <p/><asp:Label ID="Label1" Runat="server" />
        </div>
    </form>
</body>
</html>

備註

使用 UP。瀏覽器 4.1 或 UP。Browser 3.2, Redirect 除非已明確將 Web.config 區段中的 屬性設定 true 為 ,否則 Cookieless 方法的行為就像 SupportsRedirectWithCookie 物件的 false 屬性值 HttpBrowserCapabilitiesSessionState 一樣。

在 ASP.NET 1.1 中,此設定的選項為 truefalse ,但在 ASP.NET 2.0 中,選項會展開,而且 AutoDetect 現在是預設設定。 如果您的 Web 應用程式具有 cookieless 設定為布林值之Web.config檔案中 區段的 <sessionState> 屬性, Redirect 這些瀏覽器應該如預期般運作。

適用於