Last post Sep 16, 2019 03:35 PM by Mikesdotnetting
Sep 16, 2019 02:51 PM|shahid.majeed|LINK
In my web application i am creating a word file form template file and save at server.
when user click at download button i create word file with dynamic content and save at specific path at server.
File name is constant e.g "DOC.docs".
Now content is change and user click download button again then my code generate file with same name "DOC.docs" and save into it.
But once document is download at user end user get the old file. Eventhough my code update the file with new content.
So i was thinking my webserver hold the file in cach and return the old file because file name is exactly same.
Any idea how to solve?
Sep 16, 2019 03:35 PM|Mikesdotnetting|LINK
Most likely the browser is caching the file. You can stop this happening by setting Response.Cache.SetCacheability(HttpCacheability.NoCache); in the handler that manages your file download.
If you aren't using a generic handler to serve the file, you should do.
Alternatively, append a random query string value to the download link. How you do this depends on the version of ASP.NET that you are using. You can use Guid.NewGuid to generate the value:
var link = "/docs.doc?_=" + Guid.NewGuid();