天天看点

Asp.net Forms认证流程

基于用户(users)的Forms认证

1.读取Cookie取得认证信息

 User.Identity.IsAuthenticated

2.已认证,允许浏览页

3.未认证,跳到登录页面

4.登录验证用户

5.正确,用户授权写入Cookie,跳转到浏览页

 FormsAuthentication.SetAuthCookie(UserEmail.Value, PersistCookie.Checked);

 string url=FormsAuthentication.GetRedirectUrl(UserEmail.Value, PersistCookie.Checked);

 Response.Redirect(url);

 //写cookie

 //FormsAuthentication.RedirectFromLoginPage(UserEmail.Value, PersistCookie.Checked);

6.不正确,提示错误,不跳转

基于角色(roles)的Forms认证

1.读取Cookie取得认证信息

2.已认证,转4

3.未认证,跳到登录页面

4.读取相应roles,并设置角色

5.正确角色,允许浏览页

6.不正确角色,跳到登录页面

7.登录验证用户

8.正确,设置roles,用户授权写入Cookie,跳转到浏览页

9.不正确,提示错误,不跳转