后来找了N多方案均无法解决.
其中
Code
System.IO.FileInfo DownloadFile = new System.IO.FileInfo(Server.MapPath("test.mp3"));//别的服务器不行.
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ClearHeaders();
System.Web.HttpContext.Current.Response.Buffer = false;
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
System.Web.HttpContext.Current.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
System.Web.HttpContext.Current.Response.WriteFile(DownloadFile.FullName);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
这个test.mp3,换成http://sdkfsdkf.com:888/sdm.mp3的格式就提示uri格式不正确. System.IO.FileInfo DownloadFile = new System.IO.FileInfo(Server.MapPath("test.mp3"));//别的服务器不行.
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ClearHeaders();
System.Web.HttpContext.Current.Response.Buffer = false;
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
System.Web.HttpContext.Current.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
System.Web.HttpContext.Current.Response.WriteFile(DownloadFile.FullName);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
后来在这里找到.
http://support.microsoft.com/kb/283093/zh-cn
客户机可按照如下的步骤设置.
以前是从客户端设置的,在服务器端也可以加http头,这样请求返回时以文件形式,不过高兴的是我的网站没有其它页面,只有音频文件.哈哈.
Content-Disposition
attachment