做这样的事情时: Response.Clear();Response.OutputStream.Write(buffer, 0, buffer.Length);Response.ContentType = "audio/mpeg";Response.Flush(); 下载的文件名是“Default.aspx”.如何将其更改为“a.mp3”? var cd = new C
Response.Clear(); Response.OutputStream.Write(buffer, 0, buffer.Length); Response.ContentType = "audio/mpeg"; Response.Flush();
下载的文件名是“Default.aspx”.如何将其更改为“a.mp3”?
var cd = new ContentDisposition { FileName = "file.mp3" }; Response.AddHeader("Content-Disposition", cd.ToString());
ContentDisposition是一个方便的类,允许您以友好的方式设置Content-Disposition标头,而不需要知道HTTP协议的内部.当然,如果您愿意,可以手动设置标题:
Response.AppendHeader("Content-Disposition", "attachment; filename=file.mp3");