asp.net mvc - Trying to force a refresh of most up to date image, after new image uploaded, using MVC3/Razor? -
i using mvc3, razor, c#, ef4.1, mssql2008
i have implemented mechanism upload files web server "uploads" folder.
the issue have when user returned "upload" view, image still old one. may linked fact using pk of user's organisation filename ie 100.png. swapping image produce 100.png, ie overwrite original. prevents lots of rubbish files if used guid instead. browser thinks nothing has changed loads it, guess, out of cache.
my razor code is:
if (file.exists(server.mappath("~/uploads/" + strimagefilename))) { <p><img alt="current image" src="@href("~/uploads/" + strimagefilename)"/> </p> } else { <p><img alt="current image" src="@href("~/uploads/noimagefile.png")"/> </p> } if issue, shift refresh job, although automatic. there way force refresh, via code, newest image shown. did seem have more issues chrome reason.
thoughts?
thanks in advance.
changing url referenced link seems lightweight solution on using ajax.
http://www.immense.net/force-update-cached-files-images-favicon/
by adding arbitrary version number. browser update cashed image current version.
<img alt="current image" src="@href("~/uploads/" + strimagefilename + version )" you might want use action return image on direct url image. if not doing so.
Comments
Post a Comment