473,395 Members | 1,608 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,395 software developers and data experts.

browser BACK button doesn't tigger the page_load event of asp.net

joe
Logout question

I use a session to store the login information, say Session("Login") = success

and use page_load to test the session("Login") success or not

say If Session("Login") <success then response.redirect("LoginPage.aspx")

But when i use logout to set Session("Login") = "" then redirect to LoginPage,

the user click BACK button of the browser, the asp.net will not run the
page_load event
, so i can't check the Session("Login"), what can do this?
Dec 5 '06 #1
1 7040
Perennial problem.

You could try to disable the Back button (e.g. by deleting the browser
history). Disadvantages are that it annoys users and is, anyway, only
partially successful.

Another strategy is to maintain an application state object on the server.
If the user uses the Back button, it will behave as you say, but when an
event does occur, you can check the consistency of the state object and if
it is not consistent, redirect the user. This means that you need to check
consistency on just about every postback, so it's expensive and still not
very friendly.

In your case, it seems to me that a better solution is to use forms
authentication and then to use attributes on your Pages to raise a security
challenge each time the page is accessed. This will also allow you to use
role-based security as well, should you need it. You can also put
attributes on any methods you don't want to run unless the user is logged
in. None of this means that your users will not be able to use the back
button, but it does mean that they will be returned to the login page at the
first security challenge.

When users logout, however they do that (e.g. submitting a final form,
clicking a Sign Out button or whatever), you will need to make sure you use
FormsAuthentication.SignOut() and Session.Abandon(). You should also set
your Session to time out after a reasonable interval - depending on your
application's requirements.

HTH
Peter
"joe" <jo*@discussions.microsoft.comwrote in message
news:3A**********************************@microsof t.com...
Logout question

I use a session to store the login information, say Session("Login") =
success

and use page_load to test the session("Login") success or not

say If Session("Login") <success then
response.redirect("LoginPage.aspx")

But when i use logout to set Session("Login") = "" then redirect to
LoginPage,

the user click BACK button of the browser, the asp.net will not run the
page_load event
, so i can't check the Session("Login"), what can do this?

Dec 5 '06 #2

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

Similar topics

3
by: Rob | last post by:
Each time a webform is posted back (submitted), another URL is added to the browser's history list. My web application allows a back button to return to previously visited pages, but I do not wish...
5
by: Selden McCabe | last post by:
I have a page that displays a picture. In the page load I figure out which image and then do a StudentPicutre.imageurl = <some file name> But if you use the browser's back button, enter...
7
by: zdrakec | last post by:
Hello all: I note in my application, that when I use Server.Transfer("somepage.aspx"), when the new page is loaded, and I click the Back button on the browser, that the previous page, when it...
1
by: Denise | last post by:
In my application, I am setting cookies used for other pages based on the current row selected. But when the user presses the 'back' button, the pageload event does not get called and the record...
4
by: planetthoughtful | last post by:
Hi All, I have a relatively simple web user control I've included in a page that simply presents 3 drop down lists and a submit button, that I use as a date picker (ie one list for day, one for...
15
by: tshad | last post by:
I was looking for a way to handle refreshes (user pressed refresh button) and found a piece of code to check if a Web page was refreshed but I can't get it to work. The code is:...
6
by: hemant.singh | last post by:
Hi all, I am trying to get a way by which I'll know exactly when user goes out of my site by clicking on close button in browser, So that w/e user click close button in browser, I can send a...
3
by: Ian Semmel | last post by:
Is there a way to get the Page_Load event to fire if the user clicks the Back button on the browser rather than clicking a hyperlink ?
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.