共用方式為


HttpCapabilitiesBase.SupportsRedirectWithCookie 屬性

定義

會獲得一個值,表示瀏覽器是否支援 Cookies 的重定向。

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

屬性值

true如果瀏覽器支援重定向時的 Cookies;否則,。 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。在瀏覽器 3.2 中,Redirect該方法的行為就像物件屬性的值SupportsRedirectWithCookieHttpBrowserCapabilitiesfalse,除非 Cookieless Web.config 的屬性SessionState被明確設為 true

在 ASP.NET 1.1 版本中,這個設定的選項是 truefalse,但到了 ASP.NET 2.0,選項被擴展,現在 AutoDetect 成為預設設定。 如果你的網頁應用程式在 Web.config 檔案中將 cookieless 該區段的屬性 <sessionState> 設定為布林值, Redirect 這類瀏覽器應該能正常運作。

適用於