public IActionResult GetPDFFile() { byte[] buffer = _fileAppService.GetPDFFile(); if (buffer != null) { HttpContext.Response.ContentType = "application/pdf"; HttpContext.Response.Headers.Add("content-length", buffer.Length.ToString()); HttpContext.Response.Body.Write(buffer, 0, buffer.Length); } return(new ContentResult()); }
public IActionResult Get() { var buffer = _fileAppService.GetPDFFile(); //if(buffer != null){ // HttpContext.Response.ContentType = "application/pdf"; // HttpContext.Response.Headers. // HttpContext.Response.Headers.Add("content-length", buffer.Length.ToString()); // HttpContext.Response.Body.Write(buffer, 0, buffer.Length); //} return(File(buffer, GetContentType("xxx.pdf"), "pdf")); }