title: Extract pdf from database and display it on my cshtml
body: <p>i working on a project, that shall show resturant information along with an pdf file. I have been able to save my pdf to my database. But i don't know how to extrakt it from my database and then display it on my .cshtml.</p>
  
  <p>I'm working with VS and MVC4 with an MSSQL server.</p>
  
  <p>Heres the code to download the file.</p>
  
  <pre><code>var fileName = Path.GetFileName(TempVM.Resturang.PDF_File.FileName);
  var filePath = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
  TempVM.Resturang.PDF_File.SaveAs(filePath);
  
  FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
  BinaryReader br = new BinaryReader(fs);
  Byte[] bytes = br.ReadBytes((Int32)fs.Length);
  br.Close();
  fs.Close();
  
  TempVM.Resturang.PDF_FileName = fileName;
  TempVM.Resturang.PDF_Data = bytes;
  TempVM.Resturang.PDF_ContentType = filePath; 
  </code></pre>
  
  <p>The file comes from the object </p>
  
  <pre><code>public HttpPostedFileBase PDF_File { get; set; }
  </code></pre>
  
  <p>And the data is stored as </p>
  
  <pre><code>[PDF_Data]    VARBINARY (MAX) NULL,
  [PDF_ContentType] VARCHAR(MAX) NULL, 
  [PDF_FileName] VARCHAR(MAX) NULL,
  </code></pre>
  
  <p>With the sql code to store it</p>
  
  <pre><code>cmd.Parameters.Add("@PDF_FileName", SqlDbType.VarChar).Value = Resturang.PDF_FileName;
  cmd.Parameters.Add("@PDF_ContentType", SqlDbType.VarChar).Value = Resturang.PDF_ContentType;
  cmd.Parameters.Add("@PDF_Data", SqlDbType.VarBinary).Value = Resturang.PDF_Data;
  </code></pre>
  
  <p>But know i dont know how to extrakt my pdf file stored in my database and then display it on my .cshtml page so i can view it and mayby download it from the -cshtml page.</p>