[英]How to end the user session and make sure that the user is logged out?
I am new to .aspx and now the thing is since i am doing a web enabled project, I have this login from an user. 我是.aspx的新手,现在问题是因为我正在做一个支持Web的项目,我从用户那里登录。 I drag dropped the login template and then used the 我拖放了登录模板,然后使用了
Session["Authentication"] = username.Tostring();
to store the current logged user's info and so. 存储当前登录用户的信息等等。 Now i even used a hyperlink "Logout" at the top right corner and then made it transfer to Login page. 现在我甚至在右上角使用了一个超链接“Logout”,然后将其转移到Login页面。 ( If this is wrong way of transfering Please Let me know, I am Learning all by internet).. (如果这是错误的转移方式请让我知道,我通过互联网学习所有)..
Now if on running the web , i can easily login , but when i logout through hyper link "logout" it will take me to the Login page again, but if i press the back button of the browser it again transfers the control to the data page and i can again perform the data operation's. 现在,如果在网上运行,我可以轻松登录,但是当我通过超级链接“注销”注销时,它会再次进入“登录”页面,但如果我按下浏览器的后退按钮,它会再次将控件传输到数据页面,我可以再次执行数据操作。
I used this 我用过这个
Session["Authenticate"] = null
at the page load of the login page so that only at the login button click the user can enter again by 在登录页面的页面加载时,只有在登录按钮单击时,用户才能再次输入
Session["Authenticate"] = username.Tostring();
Then i used a check at each page load of the data pages 然后我在数据页的每个页面加载时使用了一个检查
if(Session[Authentiacte"] == null)
Server.Tranfer("LoginPage.aspx");
This didnt solve my problem, Please can anyone give a hint or a link or a tip to improve my way of logout? 这并没有解决我的问题,请任何人都可以给出提示或链接或提示,以改善我的注销方式? I strated this project without any knowledge of the .net or aspx and i am still learning everything, please bare my doubts thankx in advance.. 我在没有任何.net或aspx知识的情况下指导了这个项目,我仍在学习所有内容,请提前表达我的怀疑。
HttpContext.Current.Session.Clear();
HttpContext.Current.Session.Abandon();
HttpContext.Current.User = null;
System.Web.Security.FormsAuthentication.SignOut(); // if forms auth is used
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.