首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> .NET 網頁程式設計 >> ASP.NET 基礎 >> 關於ASP.NET

ASP.NET 2.0 Membership 與 RoleManager:會員資格與角色管理完整配置指南

     編輯:關於ASP.NET

ASP.NET 2.0 內建 Provider 架構的會員/角色服務,輕鬆替換為自定義實作。

驗證模式設定

  • Windows 驗證:<authentication mode="Windows" />
  • Forms 驗證:<authentication mode="Forms"> 含 <forms> 子元素詳細屬性:
<forms name=".VS2005_Form" loginUrl="~/Security/Login.aspx" defaultUrl="~/Default.aspx"
       protection="All" timeout="30" path="/" requireSSL="false"
       slidingExpiration="true" enableCrossAppRedirects="false" cookieless="UseDeviceProfile" />

Forms 關鍵屬性解析

屬性說明
cookielessUseDeviceProfile(預設)/AutoDetect/UseUri/UseCookies
defaultUrl登入成功預設導向
domain跨子域共享 Cookie(如 .cnblogs.com)
slidingExpiration每次請求重置逾期時間

會員與角色 Provider 配置

在 <membership>、<roleManager> 區段指定 defaultProvider 與連接字串,即可使用 Membership.CreateUser、Roles.AddUserToRole 等靜態 API,零代碼實現完整帳號體系。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved