473,385 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to prevent seeing previous page after logout?

Hi,

I want to prevent the user from viewing the previous page using the Back
button after logout. I want to instead show that this page has expired.
How do I do this?

Here is my codebehind on the logoff page.

private void Page_Load(object sender, System.EventArgs e)
{

Session.Abandon();

FormsAuthentication.SignOut();

Response.Redirect("index.aspx");

}

I tried the following and none of them worked.
1. Added a no-cache meta tag.

2. Tried including the following code in page-load of logout.
Response.Clear();

Response.BufferOutput = true;

Response.Cache.SetExpires(DateTime.Now);

Response.Cache.SetCacheability(HttpCacheability.No Cache);

Response.Cache.SetNoStore();

Response.Write("");

Response.End();

What am I missing or doing wrong?

Regards,
Anand
May 24 '06 #1
5 12216
V
You can use Javascript to get the desried effect:

Check out the link below

http://www.htmlgoodies.com/tutorials...le.php/3478911

- Vaibhav

May 24 '06 #2
The browser caches pages. So when one goes back to that page, it is the
same cahced copy that is being displayed. I personally dont think that
setting cacheability to NoCache for the LogOff page would help. The
page that you see when you click on the Back browser button needs that
setting.

Thus potentially all the pages that might link to the LogOff page need
to set Cacheability to NoCache.

Hope that would be the solution.

Again. Dont take me on my word. Test the above scenario first to see if
it works. I am also a learner.

May 24 '06 #3
Hi Daanish,

I tried this earlier and it had no effect.

Technically, I want the user to navigate back and forth if he's logged in.

I want a 'Page Expired' warning only when he has logged out and hits back.

Any clue? I am sure this should be possible but dunno how. :~)

Regards,
Anand

"DaanishRumani" <da************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
The browser caches pages. So when one goes back to that page, it is the
same cahced copy that is being displayed. I personally dont think that
setting cacheability to NoCache for the LogOff page would help. The
page that you see when you click on the Back browser button needs that
setting.

Thus potentially all the pages that might link to the LogOff page need
to set Cacheability to NoCache.

Hope that would be the solution.

Again. Dont take me on my word. Test the above scenario first to see if
it works. I am also a learner.

May 25 '06 #4
Hi Daanish,

I tried this earlier and it had no effect.

Technically, I want the user to navigate back and forth if he's logged in.

I want a 'Page Expired' warning only when he has logged out and hits back.

Any clue? I am sure this should be possible but dunno how. :~)

Regards,
Anand

"DaanishRumani" <da************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
The browser caches pages. So when one goes back to that page, it is the
same cahced copy that is being displayed. I personally dont think that
setting cacheability to NoCache for the LogOff page would help. The
page that you see when you click on the Back browser button needs that
setting.

Thus potentially all the pages that might link to the LogOff page need
to set Cacheability to NoCache.

Hope that would be the solution.

Again. Dont take me on my word. Test the above scenario first to see if
it works. I am also a learner.

May 29 '06 #5
Well one more thing that I forgot is that in addtion to using the above
setting, you should use some session variable say 'IsUserLoggedIn'. Set
this session variable to "true" or "yes" or whatever you like when you
log on. Then at the start of each page you need to check this variable
if it is equal to "true" or "yes". If it is so, then you would do
nothing and show the page normally. If the session variable is not
defined or it is set to anything other than that, then redirect to the
page that shows "your session has timed out" or "your session no longer
exists".

Remember that you would be setting this variable to "false" or "no"
when you sign out.

See below to get an Idea what I am saying.
1) When signing in:
Session("IsUserLoggedIn") = "true"
2) When signing out:
Session("IsUserLoggedIn") = "false"
3) At the start of each page that the user can see only when logged In:
if(Session("IsUserLoggedIn") == "true")
{
// do nothing
}
else
{
Response.Redirect("SessionHasExpired.aspx")
}

Ignore the syntax errors above. I just intend to better explain the
logic.

Session variables are maintained different for each user session by the
Web Server and the session timeout can be set at the Web Server
(IISAdmin).

--
daanish dot rumani at gmail.com

May 29 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Daniel Walzenbach | last post by:
Hi I am faced with the following problem: I have a page (let’s call this page page1.aspx) containing some TextBoxes and a hyperlink which opens another page (let’s call this page page2.aspx)...
3
by: venky | last post by:
Hi, I have a question regarding page navigation. See i have a page called page1.aspx and page2.aspx. On some event in the both the pages the page get transfered to page3.aspx using...
1
by: sri_san | last post by:
Hello, I am working on a website where I need to navigate to the previous page once the user clicks on "back" button. I store the previous page from the "HTTP_REFERER" Server variable and the...
2
by: TR | last post by:
In an "Abandon Changes" button on my UserPreferences.aspx form, I'd like to redirect back to the page the user was on before coming to the UserPreferences form. It could be any one of my web app's...
1
by: Jeff | last post by:
I need to place a "Previous Page" link on every page within my site and a simple javascript:history.back() will not work because I need it to capture the state of the page when I left it. For...
3
vijcbe
by: vijcbe | last post by:
Hello friends!! Hope someone will fix this issue for me.. I am making a web page in PHP, in which users will enter into their login and do manupulations. After they click logout, the go to the...
2
by: Matsam | last post by:
Hi, I have an ASP page that displays the account details of individual users, to which they can login using their user name & password. I have given a link for "Logout". When a user clicks this...
4
by: =?Utf-8?B?QXNhZg==?= | last post by:
Hi, How can I prevent from an ASP.NET page to resend all the data again when the user press the Refresh button or F5 on the browser? Thanks in advanced, Asaf
13
by: staeri | last post by:
I use javascript:history.go(-1) to return to the previous page. I've now found out that when returning to the previous page all selections that the user made in dropdownlists are lost. How can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.