如何通过c#.net中的web.config文件终止会话? [英] how to session expire by web.config file in c# .net?

查看:73
本文介绍了如何通过c#.net中的web.config文件终止会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在c#.net中创建用于登录的会话
登录后,进入欢迎页面.
当我注销时,我会在登录页面上重定向,但是会话没有过期.
当我单击后退"按钮时,欢迎页面直接打开...
所以请帮我如何使会话过期??

i create a session for login in c# .net
when i log in i go to on welcome page.
when i logout i redirect on login page but there is session is not expire.
when i click on back button welcome page is direct open...
so please help me how can i expire session...?

推荐答案

这些页面可能被浏览器缓存了吗?
使用Session.Abandon()登出并

<%@ OutputCache Location ="None"%>
May be these pages are cached by browser?
Use Session.Abandon() to logout and

<%@ OutputCache Location="None" %>


在注销"按钮的clik事件上添加此代码(如果是服务器端控件,则可以使用处理程序执行此操作)代码
您还可以在login.aspx页面的加载事件上尝试使用此代码



System.Web.Security.FormsAuthentication.SignOut();
Session.Clear();
Session.Abandon();
Add this code on clik event of "Logout" button if that is server side control other wise u can use handler to execute this code
u can also try this code on load event of login.aspx page



System.Web.Security.FormsAuthentication.SignOut();
Session.Clear();
Session.Abandon();


这篇关于如何通过c#.net中的web.config文件终止会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆