語言

Roles.CookiePath 屬性

定義

取得快取角色名稱 cookie 的路徑。

public:
 static property System::String ^ CookiePath { System::String ^ get(); };
public static string CookiePath { get; }
static member CookiePath : string
Public Shared ReadOnly Property CookiePath As String

屬性值

Cookie 中角色名稱快取的路徑。 預設值為 /。

範例

以下範例展示了 ASP.NET 應用程式 Web.config 檔案區塊中的 system.web 元素。 它指定應用程式使用 SqlRoleProvider 實例,並將屬性設定 cookiePath 為 /MyApplication。

<roleManager defaultProvider="SqlProvider"
  enabled="true"
  cacheRolesInCookie="true"
  cookieName=".ASPROLES"
  cookieTimeout="30"
  cookiePath="/MyApplication"
  cookieRequireSSL="false"
  cookieSlidingExpiration="true"
  cookieProtection="All" >
  <providers>
    <add
      name="SqlProvider"
      type="System.Web.Security.SqlRoleProvider"
      connectionStringName="SqlServices"
      applicationName="MyApplication" />
  </providers>
</roleManager>

備註

你可以在 ASP.NET 應用程式的 Web.config 檔案中設定 cookiePath 屬性,來指定 cookie 角色快取的路徑。 欲了解更多關於 cookie 路徑的資訊,請參見 Path。

適用於

另請參閱