我在mvc中使用下面的代码来下载Excel文件,但它显示错误查询字符串太长。错误:http查询字符串太长
public ActionResult Download(string input)
{
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment; filename= download.xlsx");
Response.AddHeader("Content-Type", "application/Excel");
Response.ContentType = "application/vnd.ms-excel";
Response.WriteFile(input);
Response.End();
return Content(String.Empty);
}
什么是文件名?你能把它复制到一个较短的文件路径名称的临时位置吗? – DLeh 2014-12-03 15:27:45
什么是问题? – Eun 2014-12-03 15:28:01
也应该使用'File()'方法而不是直接写入响应。用法:'下载(字符串输入){返回文件(“download.xlsx”); }' – DLeh 2014-12-03 15:28:59