asp.net网站后台安全退出

来源:互联网 发布:电脑温度软件2017 编辑:程序博客网 时间:2024/04/28 21:21
1.在配置文件进行如下设置:


<authorization>
     <deny users="?"/>      <!--此节点设置匿名用户不能登录-->
     <allow roles="admin"/>  <!--此节点设置匿名用户不能登录的文件夹-->
 </authorization>


 


<authentication mode="Forms">
     <forms loginUrl="Login.aspx" name="test"></forms>  <!--匿名登录时跳转到登录页面-->
</authentication>


注意:这两个节点都在<system.web>节点中


2. 在登录页面中当登录成功时添加代码:


string strRedirect = Request["ReturnUrl"];


System.Web.Security.FormsAuthentication.SetAuthCookie(user.UserName, false);
if (strRedirect == null)
            Response.Redirect("Default.aspx");            
Response.Redirect("admin/adminMain.aspx");  //跳转到后台主页面


3. 在后台主页面的安全退出超链接上设置时:


<a href="../Login.aspx" onclick="javascript:location.replace(this.href); event.returnValue=false;">退出</a>
0 0
原创粉丝点击