.net 如何不被讯雷拦截下载的文件?
public void down(string url)
{
System.IO.FileInfo DownloadFile = new FileInfo(url);
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DownloadFile.Name, System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.Clear();
Response.Close();
HttpContext.Current.ApplicationInstance.CompleteRequest();
} --------------------编程问答-------------------- 上面这代码中 ,如果我安装了讯雷的话,会被拦截了地址,直接跳出来一个网页的地址,请问怎么解决 --------------------编程问答-------------------- 把讯雷的监视插件清理掉,
或是把下载写成流的方式, --------------------编程问答-------------------- //流方式下载
protected void Button4_Click(object sender, EventArgs e)
{
string fileName = "aaa.txt";//客户端保存的文件名
string filePath = Server.MapPath("DownLoad/aaa.txt");//路径
//以字符流的形式下载文件
FileStream fs = new FileStream(filePath, FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
Response.ContentType = "application/octet-stream";
//通知浏览器下载文件而不是打开
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
这样写同样会被拦截了地址,还有什么改进的方法吗? --------------------编程问答-------------------- 点击下载按钮,跳转到一个随便的页面,里边写下载的代码。代码最后然后吧那个页面关了。
补充:.NET技术 , C#