为用户下载的文件设置默认文件名

public void ProcessRequest(HttpContext context)
{
    byte[] fileContent = GetFileContent();
    context.Response.ContentType = "application/octet-stream";
    string downloadName = "Medical-Evaluation-Result.xlsx";
    string headerValue = string.Format("attachment; filename=\"{0}\"", downloadName);
    context.Response.AddHeader("Content-Disposition", headerValue);
    context.Response.OutputStream.Write(fileContent, 0, fileContent.Length);
}

 

posted @ 2019-02-28 17:13  Adrian_Bai  阅读(249)  评论(0)    收藏  举报