我有電子商務網站並上傳了一些mp3文件,客戶可以將mp3文件下載到電腦上,但是當他們嘗試將它們下載到iPad時,iPad無法下載它們。爲什麼iPad不能下載mp3文件?
下載文件的代碼如下
public static void DownloadAudio(string url)
{
if (HttpContext.Current.CurrentHandler is basePage)
{
HttpContext.Current.Response.Clear();
string fileDiskPath = HttpContext.Current.Server.MapPath(url);
FileInfo fileInfo = new FileInfo(fileDiskPath);
HttpContext.Current.Response.ContentType = "audio/mp3";
HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", fileInfo.Name));
HttpContext.Current.Response.AddHeader("Content-Length", fileInfo.Length.ToString());
HttpContext.Current.Response.WriteFile(fileDiskPath);
//HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}
else
{
throw new NotSupportedException("Note: This method is not supporting user controls. Consider supporting user controls by getting the parent page from user control.");
}
}
那麼...... iPad上的用戶試圖下載mp3會發生什麼? – Gromer
消息出現說「Safari瀏覽器無法下載文件」 –