Content-Disposition属性有两种类型:inline 和 attachment
inline :将文件内容直接显示在页面
attachment:弹出对话框让用户下载
code:
context.Response.ContentType = "text/plain";
string fileName = context.Request["fileName"];
if(fileName!=null)
{
context.Response.AddHeader("Content-Disposition", "attachment;filename="+fileName);
context.Response.WriteFile("downLoad/" + fileName);
}
Content-Disposition 响应头,设置文件在浏览器打开还是下载
原文:https://www.cnblogs.com/ergougougou/p/10635569.html