大家看代码吧

System.IO.FileInfo file = new System.IO.FileInfo(Request.PhysicalApplicationPath + "/IncomeUpload/回款.xls");
Response.Clear();
/*修改前做法
  Response.AddHeader("Content-Disposition", "attachment;filename=" + file.Name);
*/
//修改后做法
Response.AddHeader("Content-Disposition""attachment;filename=" + Server.UrlEncode(file.Name));
//推荐使用
Response.AddHeader("Content-Disposition""attachment;filename=" + HttpUtility.UrlEncode(file.Name));

Response.AddHeader(
"Content-Length", file.Length.ToString());
Response.ContentType 
= "application/application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
Response.Flush();
Response.Clear();

相关文章:

  • 2022-12-23
  • 2022-02-01
  • 2021-09-07
  • 2021-10-19
  • 2021-11-23
  • 2021-10-24
  • 2022-12-23
  • 2022-03-06
猜你喜欢
  • 2022-02-06
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2021-12-17
  • 2021-12-17
相关资源
相似解决方案