簡體   English   中英

Content-Disposition標頭中的查詢字符串

[英]Query string in Content-Disposition header

我正在使用Response.WriteFile下載文件,並在文件名后附加時間戳,以防止IE緩存下載的文件。 但是瀏覽器在改變? _

string filePath = Server.MapPath("~/test.docx");
string fileName = string.Concat("test.docx", "?t=", DateTime.Now.Ticks);
Response.ContentType = "application/octet-stream";
Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
Response.WriteFile(filePath);
...

預期結果: test.docx

實際結果: test.docx_t=635823369853307954

這可能嗎?

瀏覽器最終將根據請求的url(和其他標頭)緩存結果,而不是“ content-disposition”響應標頭中的filename屬性。

只有當他決定再次調用Web服務器並獲得響應后,瀏覽器才知道后者:如果它已經決定使用緩存,它將不會向服務器發送任何新請求。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM