ASP.NET Refresh page after image is loaded

I have an ASPX page where I upload an image to the server for a server click event. On my page, it will show the available image if it exists. When I upload the image, it will replace the old one with the new one. Now the same image is displayed after loading as well. How can this be solved? I used the window.location.reload () javascript function to update, but then it doesn't work. He publishes the page again.

This is my code

    Do UploadImage(studentId,mode);  // Function to upload image
    StringBuilder sbc = new StringBuilder();

    sbc.Append("<script language='javascript'>");
    sbc.Append("alert('Upload process completed successfully!');");
    sbc.Append("window.location.reload()");
    sbc.Append("</script>");
    HttpContext.Current.Response.Write(sbc);

      

0


source to share


4 answers


It is cached in the browser. To overcome this, change the image url. This can be done by including a timestamp, version number or guid in the image file name.



+2


source


Your browser is probably caching the image. Either disable image caching or configure the correct caching responses.



+2


source


You can restart the server from the side

Response.Redirect(Request.URL)

      

0


source


A useful tool for debugging this is fiddler . As others have already suggested that the browser is caching the old version of the image. If you are using IIS, you can change the caching policy so that the browser always checks for a newer version of the image.

0


source







All Articles