我想在浏览器中显示pdf我已经完成了部分,但它没有显示pdf,它直接下载pdf,我不想要我想直接在这里显示pdf是我的代码。
[Route("api/DiagnosticDetail/RetrieveFile/{id}")]
[HttpGet]
public HttpResponseMessage RetrieveFile(int id)
{
DiagnosticDetailModel diagnosticDetailModel = GetFileList(id);
byte[] img = diagnosticDetailModel.FileContent.ToArray();
HttpResponseMessage result = Request.CreateResponse(HttpStatusCode.OK);
result.Content = new ByteArrayContent(img);
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline");
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
return result;
}
private DiagnosticDetailModel GetFileList(int id)
{
var DetList = db.DiagnosticDetailModels.Where(p => p.InpatientCodeId == id).FirstOrDefault();
return DetList;
}