title: Open a pdf file(using bytes) stored in Azure Blob storage
body: <p>I am trying to tweak the old logic to support files from blob, Can anyone guide me how to open a pdf file which is stored in azure blob storage.</p>
  
  <p>I tried to search and found the answer <a href="https://stackoverflow.com/questions/30467013/how-to-download-a-file-to-browser-from-azure-blob-storage">How to download a file to browser from Azure Blob Storage</a>
  which is using SAS configuration to do that (if i am not wrong).</p>
  
  <p>Is there any way to do by converting to bytes?</p>
  
  <p>Earlier logic to open a pdf file from windows location</p>
  
  <pre><code>Response.Buffer = true;
  Response.Clear();
  Response.ClearContent();
  Response.ClearHeaders();
  Response.ContentType = "application/pdf";
  Response.AppendHeader("content-disposition", "inline; filename=" + mapid + ".pdf");
  
  FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
  BinaryReader br = new BinaryReader(fs);
  Byte[] dataBytes = br.ReadBytes((int)(fs.Length - 1));
  Response.BinaryWrite(dataBytes);
  br.Close();
  fs.Close();
  </code></pre>
  
  <p>I am rewritting the logic to read the file from blob, below code is what i have tried so far,</p>
  
  <pre><code>Byte[] dataBytes1;
  CloudBlockBlob blobfile = GetStorageAccount(true).GetBlockBlobReference(filename);
  blobfile.FetchAttributes();
  
  using (StreamReader blobfilestream = new StreamReader(blobfile.OpenRead()))
  {
      dataBytes1 = blobfilestream.CurrentEncoding.GetBytes(blobfilestream.ReadToEnd());
  }
  Byte[] value = BitConverter.GetBytes(dataBytes1.Length - 1);
  Response.BinaryWrite(value);
  </code></pre>
  
  <p>But the file is not opening with error "Failed to Load".
  Can anyone guide me if this is good approach to do it?</p>