点击mp3链接时播放而不下载的问题.

该博客为转载内容,转载自https://www.cnblogs.com/jciwolf/archive/2008/12/04/1347309.html ,未提及具体信息技术相关关键信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用户点击mp3下载链接经过一次跳转,然后有的机子就提示让下载,有的就提示让播放.

后来找了N多方案均无法解决.
其中
ContractedBlock.gif ExpandedBlockStart.gif 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格式不正确.

后来在这里找到.

http://support.microsoft.com/kb/283093/zh-cn



客户机可按照如下的步骤设置.

1.jpg
2.jpg


3.jpg


以前是从客户端设置的,在服务器端也可以加http头,这样请求返回时以文件形式,不过高兴的是我的网站没有其它页面,只有音频文件.哈哈.
Content-Disposition
attachment






转载于:https://www.cnblogs.com/jciwolf/archive/2008/12/04/1347309.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值