<a onclick=ViewPdf(test.pdf) href="">
function ViewPdf(FileName) {
var url = '../Home/GetPDF?fileName=' + FileName;
window.open(url, '_blank');
}
次に、以下のようにActionResultを記述します
public ActionResult GetPDF(string fileName)
{
try
{
byte[] fileData = System.IO.File.ReadAllBytes(Functions.GetConfigValue("CDXFilePath") + fileName);
string resultFileName = String.Format("{0}.pdf", fileName);
Response.AppendHeader("Content-Disposition", "inline; filename=" + resultFileName);
return File(fileData, "application/pdf");
}
catch
{
return File(Server.MapPath("/Content/") + "FileNotFound.html", "text/html");
}
}