. , http- (.ashx) - .
-
<a href="MyMp3Handler.ashx?fileName=MyFile">Click here to download</a>
.
, ( SO)
public void ProcessRequest (HttpContext context) {
var filePath = Server.MapPath(context.Request.QueryString["fileName"].ToString()) + ".mp3";
if (!File.Exists(filePath))
return;
var fileInfo = new System.IO.FileInfo(filePath);
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", filePath));
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.WriteFile(filePath);
Response.End();
}
web.config.
, - , . , , .
, , application/octet-stream, , , . , - , PHP, mp3 , Firefox, IE Chrome, . asp.net, .