日期:2014-05-18  浏览次数:20733 次

用form验证,登录后如何登出?
<authentication   mode= "Forms ">
            <forms   defaultUrl   = "admin/main.aspx "   loginUrl= "admin/logon.aspx "   name= "MyAuthForm ">
                <credentials   passwordFormat= "Clear ">
                    <user   name= "admin "   password= "admin "/>
                </credentials>
            </forms>
        </authentication>
        <authorization>
            <allow   users= "* "/>
        </authorization>

用form验证,不需要储存用户,如何设计一个登出按钮实现登出并实现关闭IE再打开就需要重新登录?.net2.0但是没有分角色。
不知道怎么清理。

------解决方案--------------------
private void Signout_Click ( Object sender, EventArgs e ) {
FormsAuthentication.SignOut ( ); // 注销
FormsAuthentication.RedirectToLoginPage(); // 跳到登录页
}
------解决方案--------------------
如果是使用Session的话,登出只要将Session中保存用户信息的属性清空就行了吧
------解决方案--------------------
//清除coolies
HttpContext.Current.Response.Cookies.Clear();
//退出验证

System.Web.Security.FormsAuthentication.SignOut();
//清空session
Session.Remove( "loginUserID ");
Session.Clear();
Session.Abandon();
//跳转
Server.Transfer( "Login.aspx ");
------解决方案--------------------
清Session,
清coolies(如果你用了的话),
调用System.Web.Security.FormsAuthentication.SignOut();
页面转向
------解决方案--------------------
2楼是对的.不过还需要清空你的session
------解决方案--------------------
可以用 LoginStatus 控件
------解决方案--------------------
清seesion