Content-Disposition 响应头,设置文件在浏览器打开还是下载
生活随笔
收集整理的這篇文章主要介紹了
Content-Disposition 响应头,设置文件在浏览器打开还是下载
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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);
??????? }
轉載于:https://www.cnblogs.com/ergougougou/p/10635569.html
總結
以上是生活随笔為你收集整理的Content-Disposition 响应头,设置文件在浏览器打开还是下载的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jquery ajax post请求连续
- 下一篇: es6-变量的解构赋值