TUS11
asked on
how to expired previous page when we click on back button in asp.net
how to expired previous page when we click on back button in asp.net
uuups,
Forgot to add the code:
Put that on the top of the aspx page or on code behind.
This will make the page not to be cached and when clicking back button in browser - it will not have anything to display except Web page expired.
------------------------
You can find me on: http://extremedev.blogspot.com
Forgot to add the code:
<% System.Web.HttpContext.Current.Response.AddHeader( "Cache-Control","no-cache")
System.Web.HttpContext.Current.Response.Expires = 0
System.Web.HttpContext.Current.Response.Cache.SetN oStore()
System.Web.HttpContext.Current.Response.AddHeader( "Pragma", "no-cache")%>
Put that on the top of the aspx page or on code behind.
This will make the page not to be cached and when clicking back button in browser - it will not have anything to display except Web page expired.
------------------------
You can find me on: http://extremedev.blogspot.com
ASKER
Hi,
i add the above code on page load of the first page and when i redirect to second page from the first page then if i use the back button on second page then it does not expired page message. it show the first page.
Please help me bcoz it is urgent for me.
Thanks
i add the above code on page load of the first page and when i redirect to second page from the first page then if i use the back button on second page then it does not expired page message. it show the first page.
Please help me bcoz it is urgent for me.
Thanks
Setting these seems to work in a quick test for me:
Keep in mind, though, that ultimately it's up to the web browser and there is no guarantee that the browser will honor the cache control headers.
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Keep in mind, though, that ultimately it's up to the web browser and there is no guarantee that the browser will honor the cache control headers.
OK,
It looks like this only works if the connection is secure: https.
Otherwise you will have to use session variables and when navigate away then delete the variable from the session.
In codebehind check if page had "expired" - using the Session Variable then Redirect to a Web Page Expired page (a simple html page which you will have to create).
You will also set this:
------------------------
You can find me on: http://extremedev.blogspot.com
It looks like this only works if the connection is secure: https.
Otherwise you will have to use session variables and when navigate away then delete the variable from the session.
In codebehind check if page had "expired" - using the Session Variable then Redirect to a Web Page Expired page (a simple html page which you will have to create).
You will also set this:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
In order for page to make a postback when you click back button, so that you will be able to do your check on codebehind.------------------------
You can find me on: http://extremedev.blogspot.com
ASKER
Hi,
All above solution not working for me.
we are using http not https then in this case what i do for expiring the page.
Please help me.
Thanks
All above solution not working for me.
we are using http not https then in this case what i do for expiring the page.
Please help me.
Thanks
What browser are you using, which version of the .Net Framework, what code in your ASPX page, and how are you determining that the page is still being cached?
ASKER
hi,
I am using IE8, 2.0 .net framework.
and in code behind of ASPX page i am using this below code on page load.
System.Web.HttpContext.Cur rent.Respo nse.AddHea der( "Cache-Control","no-cache" )
System.Web.HttpContext.Cur rent.Respo nse.Expire s = 0
System.Web.HttpContext.Cur rent.Respo nse.Cache. SetN oStore()
System.Web.HttpContext.Cur rent.Respo nse.AddHea der( "Pragma", "no-cache")
For checking the page expiry i have the two page.
On first page i have a button which id redirected to the second page but i want that when we press BACK button then first page should be show the Page Expiry warning message.
and the above code i add on the first page .
Thanks
I am using IE8, 2.0 .net framework.
and in code behind of ASPX page i am using this below code on page load.
System.Web.HttpContext.Cur
System.Web.HttpContext.Cur
System.Web.HttpContext.Cur
System.Web.HttpContext.Cur
For checking the page expiry i have the two page.
On first page i have a button which id redirected to the second page but i want that when we press BACK button then first page should be show the Page Expiry warning message.
and the above code i add on the first page .
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Please cancel this request
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for TUS11's comment http:/Q_26897839.html#35189676
for the following reason:
OK solution
Accepted answer: 0 points for TUS11's comment http:/Q_26897839.html#35189676
for the following reason:
OK solution
I think http:Q_26897839.html#a35195100 adequately demonstrates how to force a page to expire, complete with code and a screencast.
------------------------
You can find me on: http://extremedev.blogspot.com