Sim*_*gré 0 c# asp.net mp3 http
关于我正在寻找的东西,我有一个问题......太久了!我们构建了一个应用程序,管理员可以将歌曲上传到数据库中.然后用户可以购买歌曲并单独下载.问题是,当用户使用下面的代码下载MP3歌曲时,它在Firefox和Chrome中运行良好,但在IE8中运行效果不佳仅仅是因为WMP试图打开歌曲并且它没有得到它而不是"另存为"对话框?任何关于HOW的问题我都可以强迫"另存为"diaglog吗?请注意,我在服务器上没有MP3 physicaly它在数据库中.所以我无法直接链接到歌曲......
这是我的代码:
// Remove "specials chars"
foreach (char aChar in @"/\:*?""<>| ") {
if (aChar == ' ') {
songNameAndExt = songNameAndExt.Replace(' ', '_');
} else {
songNameAndExt = songNameAndExt.Replace(aChar.ToString(), string.Empty);
}
}
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.Headers.Add("Content-Disposition", string.Format("filename={0}", songNameAndExt));
HttpContext.Current.Response.OutputStream.Write(songData, 0, songLength);
Run Code Online (Sandbox Code Playgroud)
将其更改为
HttpContext.Current.Response.Headers.Add("Content-Disposition", string.Format("attachment; filename={0}.mp3", songNameAndExt))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2542 次 |
| 最近记录: |