使用HTML5的audio元素代替ASP.NET的MediaPlayer控件,并在服务器端使用Response.OutputStream将音频数据写入响应流中。
以下是示例代码:
前端代码:
后端代码:
byte[] audioData = // 获取音频数据
Response.ContentType = "audio/mp3";
Response.AddHeader("Content-Disposition", "attachment; filename=audio.mp3");
Response.OutputStream.Write(audioData, 0, audioData.Length);
Response.End();