繁体   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