I have an image folder in my project solution. I capture the image for a customer and i keep it in it. After i fill the details I redirect to another aspx page and i take the pic and come back to registration page and map the image to an image button i am using session variable to map the image path which is in the image folder. My problem is I get the same image even if i take a new pic. I am keeping jus one pic at a time in the image folder why do i get the previous image which is not in the image folder. Am i not supposed to get the new pic which i have taken? Please elaborate more on this and provide me a solution..I would be grateful to you..
Asked
Active
Viewed 298 times
0
-
I think your browser is Caching the image.You must have written some logic to cache the image .. – Talha Hanjra Jan 30 '14 at 05:03
-
I am using session state mode="Inproc" which mode should I use – user2022468 Jan 30 '14 at 05:08
-
inProc supports Session_OnEnd event write some logic to clear cache in this event...Well TGH has given a good solution. – Talha Hanjra Jan 30 '14 at 05:17
-
thanx Talha Hanjra..I will try with the idea u gave.. – user2022468 Jan 30 '14 at 05:20
-
I have given my session timeout as 20 mins...why do i get the same image even after 20 mins is over..Please throw more light on it – user2022468 Jan 30 '14 at 05:49
-
Kindly open incognito window and test the application ..Its purely CACHE problem.I will aslo suggest you what @TGH suggested below. – Talha Hanjra Jan 30 '14 at 06:31
-
okay Talha i will do that – user2022468 Jan 30 '14 at 06:52
-
remember to vote answers and accept them.. – Talha Hanjra Jan 30 '14 at 07:18
2 Answers
1
There could be browser caching at play. One way to get around it is to add a random querystring param to the image url (a timestamp etc) to make the image url unique.
<img src="someImage.png?someParam=1234" />

TGH
- 38,769
- 12
- 102
- 135
-
-
There is an answer to a similar question here, assuming it's due to browser cache http://stackoverflow.com/questions/728616/disable-cache-for-some-images – TGH Jan 30 '14 at 05:14
-
-
0
You cannot delete browsers cache programmatically however below code will help you for disabling caching and clears existing cache from your application... Caching is your problem as you explained in question.
public static void DisablePageCaching()
{
//Used for disabling page caching
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
HttpContext.Current.Response.Cache.SetValidUntilExpires(false);
HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoStore();
}

Talha Hanjra
- 410
- 4
- 15