您的位置:首页 > 其它

About FormsAuthentication.RedirectFromLoginPage(string username, bool createPersistentCookie)

2005-09-05 10:25 721 查看
FormsAuthentication.RedirectFromLoginPage(string username, bool createPersistentCookie) is used in Froms Authenticaiton in ASP.Net application. Forms authentication, in fact is an authentication based on auth cookies, if a cookie of the Forms name which specified in Web.config file exists in client computer, the user is authenticated, else is unauthorized.

the following code create a Forms authentication Cookie, and Set authentication cookie, then redirect to originally requested URL, if requested URL does not exist, it would redirect to default.aspx by default. username: Name of the user for cookie authentication purposes. the second parm createPersistentCookie determines whether the authentication cookie is persisitent, if it is false, cookie would be expired upon closing of the browser.

FormsAuthentication.RedirectFromLoginPage (UserName.Text, false);

the statement above is equivalent to the following :

FormsAuthentication.SetAuthCookie(UserName.Text,mycheckbox.Checked);
Response.Redirect(FormsAuthentication.GetRedirectUrl(UserName.Text,mycheckbox.Checked);

More about Forms authentication : http://www.gotdotnet.com/team/student/wintellect/aspnet_tutorial.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐