这是我的代码,我尝试了以下方式来放置下载文件的功能,但它不能正常工作。它不显示保存文件对话框。
protected virtual FileResult Download(string FileName, string FilePath)
{
Response.AppendHeader("Content-Length", FileName.Length.ToString());
return File(FilePath, "application/exe", FileName);
}
并尝试过这种方式:
protected virtual ActionResult Download(string FileName, string FilePath)
{
Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName);
Response.AppendHeader("Content-Length", FileName.Length.ToString());
Response.ContentType = "application//x-unknown";
Response.WriteFile(FilePath.Replace("\\", "/"));
Response.Flush();
Response.End();
}
但两者都不起作用。我错过了什么?