asp.net-corepdfpdfviewbrowser-support

Pdf viewing cached problem on same filme name for all browsers


I developed to .net core mvc Web project. But When I tried to display PDF on web browsers(ie: Chrome, Edge, explorer, firefox..) first I save pdf as a "myfirstlist.pdf", then I updated pdf as a same name "myfirstlist.pdf" but my document changes couldnt reflected. Is that general cached problem ?

My Action Pdf viewing this:

 [HttpGet]
 public PhysicalFileResult OnGetDownload(string fileName)
 {
 string downloadPath = Path.Combine(Directory.GetCurrentDirectory(), @"C:\", fileName);
  return new PhysicalFileResult(downloadPath, "application/pdf");
 }

Solution

  • To sum up the comment here, I assume this issue results from cache, so I think we can add a timestamp in the url to make each request be unique to avoid cache.

    Like this:

    var getTimestamp=new Date().getTime();
    url = "localhost:port/getpdf?your_param=xxx&timestamp="+getTimestamp;