Ben john
Ben john

Reputation: 55

Asp Image Button Image Not Changing

Recently I came across a problem with an Image Button in an ASP.Net application.

The image file was replaced with the same name in the server when user uploads a new Image,but The image button still showed the old Image even after the page was refreshed.

Did Overcome this issue by adding a query string to the ImageButtom url

      Image1.ImageUrl="images/ID102.jpg?"+DateTime.Now.ToString("ddmmyy");

Would like to know if this is the only solution to this??

Upvotes: 2

Views: 451

Answers (3)

Arshad Mohammad
Arshad Mohammad

Reputation: 409

I always use Google Chrome's Incognito mode to discard any stored cookies/cache while testing my apps.

Upvotes: 0

SirCapy
SirCapy

Reputation: 295

You should include hours, minutes and seconds to resolve caching problem (also you can add random number but not current datetime))

Upvotes: 2

Nick Acosta
Nick Acosta

Reputation: 1910

Your browser was likely caching the old image since it had the same url.

Refresh the page with ctrl+f5 or open up your developer tools and turn off caching in the options.

You can also detect caching by hitting F12 in your browser and looking at the network tab and watching the requests. If you see a "304 Not Modified" it means it's using a cached version.

Upvotes: 0

Related Questions