これは、ファイルをダウンロードする機能を配置する方法に従って試したコードですが、正しく機能しません。ファイルの保存ダイアログは表示されません。
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();
}
しかし、どちらも機能していません。私は何が欠けていますか?