[SOLVED] How to completely refresh (ctrl+f5) a page using asp.net?

Issue

I am working with an asp.net (Dotnetnuke) project now. I need to change an image in a page dynamically. While clicking replace button (asp:Button), some times the image cannot replace dynamically on the page. While pressing ctrl+F5, it will change. My question is, how to reload cache through C# code?

Another problem is that, sometimes I replace an image in a page by storing some values to database and press ctrl+F5 for making changes in the page, but while clicking ctrl+F5 there shows a dialog box with cancel or retry buttons (both on Firefox and IE). While clicking any one of them will store the same value to database. If we again refresh the page the value in the database is 3 times.

Solution

you cannot clear browser cache.the only idea is declare a session variable in c# code in page load and set its value is 1 at the very first time

if (!IsPostBack)
            {
Session["refresh"]="1"
}

you will need to set session variable in image upload button event Session[“refresh”]=”1″
then create a refresh button .in the button event do the following
thats all.after completeing your upload,click on the refresh button.then it work as ctrl+f5 button.if you not set the session value 0 in refresh button event the last event is again takesplace.if you enter a value in database,the same task takesplace if you not set session variable 0.

   if(Session["refresh"].ToString()=="1")
   {
      Response.Write("<script type='text/javascript'>locaton.reload()</script>");
      Session["refresh"]="0";
    }

Answered By – user765970

Answer Checked By – David Marino (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *