首页 > Web开发 > 详细

05asp.net==========限制下载

时间:2016-01-26 23:25:58      阅读:192      评论:0      收藏:0      [点我收藏+]

1  public void ProcessRequest(HttpContext context)
2         {
3             context.Response.ContentType = "text/plain";
4             string encodeFileName = HttpUtility.UrlEncode("test.txt");//国际通用防止产生乱码。生成ASCII
5             context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename=\"{0}\"", encodeFileName));//在响应头中加上Content-Disposition,attachment表示以附件形式下载.
6             context.Response.WriteFile("test.txt");//输出文件内容
7         }

  

1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
4     <title></title>
5 </head>
6 <body>
7     <a href="DownLoad.ashx">下载</a>
8 </body>
9 </html>

 

05asp.net==========限制下载

原文:http://www.cnblogs.com/clcloveHuahua/p/5161825.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!