ASP.NET 2.0 內建 Provider 架構的會員/角色服務,輕鬆替換為自定義實作。
<authentication mode="Windows" /><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" />
| 屬性 | 說明 |
|---|---|
| cookieless | UseDeviceProfile(預設)/AutoDetect/UseUri/UseCookies |
| defaultUrl | 登入成功預設導向 |
| domain | 跨子域共享 Cookie(如 .cnblogs.com) |
| slidingExpiration | 每次請求重置逾期時間 |
在 <membership>、<roleManager> 區段指定 defaultProvider 與連接字串,即可使用 Membership.CreateUser、Roles.AddUserToRole 等靜態 API,零代碼實現完整帳號體系。