Roles.CookiePath 属性

定义

获取缓存角色名称的 Cookie 的路径。

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

属性值

String

在其中缓存角色名称的 Cookie 的路径。 默认值是 /。

示例

以下示例演示 ASP.NET 应用程序的 Web.config 文件中的 roleManager 元素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

适用于

另请参阅