错误:http查询字符串太长

我在mvc中使用下面的代码来下载Excel文件,但它显示错误查询字符串太长。

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);
}

此代码适用于PDF:

public FileStreamResult DownnloadPDF(int id)
        {Document document = new Document();

            MemoryStream stream = new MemoryStream();
                PdfWriter pdfWriter = PdfWriter.GetInstance(document, stream);
                pdfWriter.CloseStream = false;

                document.Open();

                formatPDF(document, model);

document.Close();

            stream.Flush(); //Always catches me out
            stream.Position = 0; //Not sure if this is required

            return File(stream, "application/pdf", "title" + ".pdf");
        }

我真的认为你的ActionResult不起作用。

链接地址: http://www.djcxy.com/p/42079.html

上一篇: Error : http query string is too long

下一篇: Forms or Basic Authentication