Browser cache problem(IE) for displaying new uploaded image with same name
2011-09-06 22:29
375 查看
/*By Jiangong SUN*/
In images management page of my back office, all the uploaded images are displayed in it.
But when i upload a new image with the same name for a existing image, the new uploaded image doesn't show immediately in IE 8 and 7(not tested in ie9).
I have to press "ctrl+F5" to clear the browser cache to display it.
Here is my code:
I've tried to clear the browser cache with the following code:
But it seems it doesn't work for this case, even if the code solved my browser cache problem recently.
So i have to make it alternatively.
I forced it to load the image with a GUID id.
imagePath = imagePath + "?id=" + Guid.NewGuid();
So even the image in browser cache has the same name with my newly uploaded image, the application will find the new image. In this way, the new image will be displayed immediately.
In images management page of my back office, all the uploaded images are displayed in it.
But when i upload a new image with the same name for a existing image, the new uploaded image doesn't show immediately in IE 8 and 7(not tested in ie9).
I have to press "ctrl+F5" to clear the browser cache to display it.
Here is my code:
if (File.Exists(Server.MapPath(filePath))) File.Delete(Server.MapPath(filePath)); if (!File.Exists(Server.MapPath(filePath))) file.SaveAs(Server.MapPath(filePath));
I've tried to clear the browser cache with the following code:
// Stop Caching in IE Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); // Stop Caching in Firefox Response.Cache.SetNoStore();
But it seems it doesn't work for this case, even if the code solved my browser cache problem recently.
So i have to make it alternatively.
I forced it to load the image with a GUID id.
imagePath = imagePath + "?id=" + Guid.NewGuid();
So even the image in browser cache has the same name with my newly uploaded image, the application will find the new image. In this way, the new image will be displayed immediately.
相关文章推荐
- Ehcache依赖版本问题:Another CacheManager with same name 'es' already exists in the same VM.
- Springmvc中配置ehcache遇到错误Another CacheManager with same name
- spring 'arroudAspect' for bean class [com.dw.test.ArroudAspect] conflicts with existing, non-compatible bean definition of same name and class [com.dw.aspect.ArroudAspect]
- Deprecated: Methods with the same name as their class will not be constructors in a future version o
- call different method with the same name, parameters and return value, select which one is called using const symbol
- Image Processing for Dummies with C# and GDI+ Part 4 - Bilinear Filters and Resizing
- obout editor Absolute path for uploaded image
- The new SFCB broker fails to start with a SSL-related error: Failure setting ECDH curve name (secp22
- Class.forName()、Class.forName().newInstance() 和 New 区别
- No mapping found for HTTP request with URI [/SpringMvc2/ItemList] in DispatcherServlet with name 'sp
- for the problem ImportError: cannot import name symbol_database 'text_format'
- Class.forName()、Class.forName().newInstance() 、New 三者区别!
- LinkageError之loader (instance of xxx) previously initiated loading for a different type with name
- 论文笔记(一)Re-ranking by Multi-feature Fusion with Diffusion for Image Retrieval
- name lookup of 'res' changed for new ISO 'res' scoping
- 解决ofbiz在myeclipse中调试运行时报错:Can't find bundle for base name cache
- TortoiseSvn :object of the same name is already scheduled for addition
- java数据库连接为何用class.forName().他和new有什么区别。
- There is no Action mapped for namespace [/] and action name [] associated with context path [/test1]
- SpringMVC conflicts with existing, non-compatible bean definition of same name and class 的解决办法