Last post Apr 04, 2011 11:02 AM by sirdneo
Mar 16, 2011 05:24 AMemail@example.com|LINK
i allow my admin to login from his login page and login information verified and stored into an session after that, he visited into an client page, there is an logout button this will visible whether session has the user id or admin user id else it'll be
now the scenario is:
1. admin logged into admin page
2. then in the address bar type the client page name
3. now the client page is check whether has the userid or admin user id in Session, now the session has admin user id so, its show the Logout button.
4. from this client page, the admin clicks on Logout button, here i have Abandon the session and moved into the admin login page.
5. now again admin types the same client page name in the address bar from his login page(but now he didnt logged in).
6. this time i set the break point on client page_load event but its not hitting the event also its visible the Logout button also.
so, how its not hitting the page_load event and why the logout button is visible after loggedout.
please guide me to resolve this issue?
Mar 16, 2011 05:41 AM|frez|LINK
The page is being loaded from the browser cache so it is not hitting the server to retrieve the page and so it does not care whether the user is logged in or not.
In order to prevent the user from typing a url and this being retrieved from the browser cache you need to request that the cache is cleared on the pages. This is not fool proof as in theory a browser is free to ignore the request to clear the cache.
What you can do is in the page init event for the page you do not want the user to return to in this way run the following code:
If you want all pages protected this way then create a class that inherits from System.Web.UI.Page and have all pages inherit from this class and then put the above code in the OnInit method you override.
Mar 16, 2011 06:41 AMfirstname.lastname@example.org|LINK
Frez thanks for your response.
i didnt get this point "
If you want all pages protected this way then create a class that inherits from System.Web.UI.Page and have all pages inherit from this class and then put the above code in the OnInit method you override."
could you please post some code reg this?
Mar 16, 2011 07:02 AM|frez|LINK
You can create a custom base class so that you dont have to include the same code on every single page it will be done for you; see this link
Your base class will contain this:
override protected void OnInit(EventArgs e)
If you already have a base class then just add the code above to the OnInit method.
Mar 17, 2011 12:44 AM|sirdneo|LINK
See this blogpost, it will guide you different ways through which you can solve your problem:-
Mar 17, 2011 02:43 AMemail@example.com|LINK
Frez, your code solved my issue.
but the same code is not working in my domain. may i know why this happend and how to resolve it?
Mar 17, 2011 04:22 AM|frez|LINK
I don't understand what you mean when you are saying it doesnt work in your domain, could you clarify?
Mar 17, 2011 05:22 AMfirstname.lastname@example.org|LINK
Frez, thanks for your response.
your code resolved my issue and its working fine in my localhost but after uploaded to my server its not working. so, could you get any issues on my server or my code.....?
Mar 17, 2011 05:55 AM|frez|LINK
My guess is that there was not a full deploy onto your server, there should be no difference in the code on your local host asking the browser not to cache the pages and the code on your server doing the same if the code is identical. Check that you have
not only deployed the new base class but all the pages that now inherit from it too.
Mar 17, 2011 07:36 AM|sirdneo|LINK
If it is working on local machine it should work on production machine as well.Kindly check these two things:-
1- Build is properly deployed on your server?
2- You have restarted your IIS?
Mar 24, 2011 12:48 AMemail@example.com|LINK
Frez you are correct. I didnt publised well, first i removed all the files from server and upload it again now its working good in Ie7 mozila's.
but the same problem exists in IE 8 standard and compatibility mode (OS: Windows Vista Ultimate Pack).
could you please tell me how to resolve this?
Mar 24, 2011 05:06 AM|frez|LINK
I have no idea why IE8 is still caching your pages, I have just created a small test project with two pages and this code:
public partial class WebForm1 : Class1
protected void Page_Load(object sender, EventArgs e)
Random r1 = new Random();
Label1.Text = Request.Path + " " + r1.Next(100);
protected void Button1_Click(object sender, EventArgs e)
Where Class1 contained this:
public class Class1 : System.Web.UI.Page
override protected void OnInit(EventArgs e)
I then deployed the code, and got a random number on page1, clicked the button to get to page2, then hit the back button to go back to page 1.
The code in Class1 worked at stopping the page being cached in IE8, and when I commented out the code in Class1 and redeployed the page started being cached again.
Mar 24, 2011 07:54 AMfirstname.lastname@example.org|LINK
free thanks for your response.
my god. why this IE8 always creating issues!!!
Freez do you know how to resolve this issue? could you please help me?
Mar 24, 2011 08:20 AM|frez|LINK
Sorry I can't help, I have no idea why your IE8 is behaving in this way when mine behaves perfectly well.
Mar 25, 2011 10:58 AMemail@example.com|LINK
it is workign fine with Windows 7 and IE 8 but not working fine with Windows Vista and IE 8. Me too trying to find the solution but i still i cant.
Mar 25, 2011 11:43 AM|frez|LINK
Try comparing the "Check for newer versions of stored pages:" option in the two versions of IE8 on the different versions of windows, you will find the option by clicking Tools | Internet Options | Browsing History Settings
Apr 01, 2011 12:50 PMfirstname.lastname@example.org|LINK
Freez, we can get the lattest version but if an user using default version(like which im using now) then that time my application will fail correct? so, is there any way to resolve this issue?
is there any way to post this issue to Microsoft?
Apr 04, 2011 09:22 AM|dheerajswami|LINK
please try again with following steps:
1. Build your project and make single page dll
2. Host Proparly on your domain
3. Restart your IIS
4. Clear All History and cookes of your browser and this will work.
Apr 04, 2011 11:02 AM|sirdneo|LINK
This is bit tricky, first you have to clear all the data from your browsers history before u get the new pages. actually IE is displaying page from your cache and even if you add cache removal statements still they wont work unless you first clear all the
cache from browser and after that your cache code will work as expected.