在asp中登录表单会话问题 [英] login form session problem in asp

查看:79
本文介绍了在asp中登录表单会话问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hii ..我已经创建了一个Asp.net(C#)login.aspx页面,然后通过登录我重定向到user.aspx页面..现在我从user.aspx页面退出时我又回来了到login.aspx页面。我使用SQL服务器作为数据库,我有一个表登录

我的问题就在这时我按下浏览器的后退按钮我再次重定向到用户。 aspx页面。这是无效的,因为我们只能在登录后移动到user.aspx页面。

我该如何解决这个问题。谁能为我提供这个解决方案。我在asp.net中使用C#作为我的语言。

请给我一个片段。我非常需要它。请帮助

我的id-rockthaworld123@gmail.com

hii..I have made an Asp.net(C#) login.aspx page and then by logging in I am redirecting to user.aspx page..now from user.aspx page when i am logging out i again come back to login.aspx page.I am using SQL server as a data base in which i have a table login
My problem is at this point when I am pressing browser's back button I am again redirecting to user.aspx page. This is not valid as we can only move to user.aspx page only after logging in.
How can i solve this problem. Can anyone provide me with this solution. I am using C# as my language in asp.net.
Please send me a snippet.I need it badly.Pls help
my id- rockthaworld123@gmail.com

推荐答案

嗨rockthaworld123,



关于这一点,我需要从你这边做一件事。用户按下注销选项时需要后退按钮功能。如果你不需要手段只是你可以禁用后退按钮设施,但它是浏览器的可靠性。通过使用以下代码,您可以在应用程序中禁用后退按钮功能





window.history.forward();

函数noBack(){window.history.forward(); }







onpageshow =if(event.persisted)noBack(); onunload =>



您需要后退按钮功能,只需在用户按下应用程序中的按钮时重定向主页



可能会对你有所帮助





谢谢和问候,

Pallamalli Maruthi
Hi rockthaworld123,

One thing i need from u r side regarding of this. you need back button pressing facility while user pressing logout option. if u dont need means simply u can disable back button facility , but it is browser dependability. By using following code you can disable back button press feature in your application


window.history.forward();
function noBack() { window.history.forward(); }



onpageshow="if (event.persisted) noBack();" onunload="">

and you need backbutton facility means simply redirect home page when the user press back button in your application

Might be it will help to you


Thanks and Regards,
Pallamalli Maruthi


另一种解决方案是,在所有页面中不使用缓存。它强制浏览器重新加载user.apsx而不是从缓存中读取。

首先,在标题中使用这些代码:

Another solution is, use no cache in all of your pages. It forces the browser to reload user.apsx instead of reading from cache.
First, use these code in your header:
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">



其次,你必须确保你的user.aspx不允许在没有有效会话的情况下直接打开。


Secondly, you must ensure that your user.aspx doesn't allow to open directly without a valid session.


试试这个,,,, :)



Try this,,,,:)

Session.Clear();//clear session
Session.Abandon();//Abandon session
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Redirect("yourUrl.aspx");


这篇关于在asp中登录表单会话问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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