如何制作下载文件 我知道做个超链就能下载了,可问题是如果遇到下载文件是.TXT.JPG等,会直接跳转到相关图片,文字页面,请问这应该如何避免? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下面方法,Insus.NET测试过您相关的问题,没有遇上过.http://www.cnblogs.com/insus/articles/1411761.html StringWriter sw = new StringWriter(); sw.WriteLine(""); sw.Close(); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=test.txt"); Response.ContentType = "application/ms-excel"; Response.ContentEncoding = Encoding.GetEncoding("gb2312"); Response.Write(sw); Response.End(); 通过输入流实现下载参考 Response.ContentType = "Application/octet-stream 貌似把文件的ContentType属性改一下就可以当成文件下载了。 不过碰到一些比较另类的浏览器还是会直接显示出来,比如Chrome 搭建网站经验 后台如何得到前台ActiveX控件 asp.net如何动态设置GridView控件中列的HTMLEncode属性? 网站头被人恶意添加了代码 URL编码有什么区别? 求一验证只能输入字母和数字的正则表达式 在ie8下为什么提交后整个页面变成html .NET中怎么提取字段类型、长度、是否为空 控件内容在ie中显示不出来 Datagrid中加了一个超连接,想自己写事件,怎么做?我的方法好象不行 <a href="resulrt.aspx?id=……">50-60</a> 我在其他页面要获取50-60 急.初学者下载了一个C#网站,但报错.请教大家.
http://www.cnblogs.com/insus/articles/1411761.html
sw.WriteLine("");
sw.Close();
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=test.txt");
Response.ContentType = "application/ms-excel";
Response.ContentEncoding = Encoding.GetEncoding("gb2312");
Response.Write(sw);
Response.End();
通过输入流实现下载
参考