Browser cache problem(IE) for displaying new uploaded image with same name
来源:互联网 发布:淘宝双十二活动报名 编辑:程序博客网 时间:2024/06/05 02:07
/*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:
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 IEResponse.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);// Stop Caching in FirefoxResponse.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.
- Browser cache problem(IE) for displaying new uploaded image with same name
- A new node couldn't be inserted because one with the same name exists. (VERR_CFGM_NODE_EXISTS)
- Displaying an image with EJS in node.js/express
- QTP - 26 Working with MS IE browser 与IE 交互
- Website Design With Standards For Browser Compatibility
- No keyword with name 'Open Browser' found(解决办法)
- How to rotate an image with CSS under different browser
- CXF A class/interface with the same name 问题
- subroutine has the same name with build_in functions
- MBean with the same name could not be unregisted
- The project contains another dependency with the same archive name.
- Old log archive with same name might be overwritten
- Qes_20170801_Two components with the same name and precedence
- Displaying Bitmap with Scrolling
- Displaying XML with XSLT
- Displaying XML with CSS
- Displaying XML with XSLT
- Displaying Bitmap with Scrolling
- hdu 1056 HangOver(水)
- linux内核定时器编程
- 不良代码展示-Android中的位运算的例子(二)
- 首次开通博客
- IOCP中的AcceptEx
- Browser cache problem(IE) for displaying new uploaded image with same name
- SQL语句中的循环、加密操作
- 线程的状态转换
- JSP中使用CKEditor3.6入门教程
- 几个出错处理的函数abort、exit、atexit、strerror函数的使用方法
- poj 1637 & zoj 1992 混合图的欧拉回路
- 用apt-get方法安装mysql5 + Apache2 + PHP5+Phpmyadmin
- 心依旧空空的。
- 考验你的分类能力!!!