title: File Download from Azure Blob
body: <p>Below code is for donwnloading file from azure blob. I have problem with .docx,.xlsx files and that too after deployment only, mean in local machine it is working fine.</p>
  
  <p>The problem is after downloading .xlsx or .docx, when i open that file showing file corrupted popup.</p>
  
  <pre><code>public void DownloadBlob(string blobName)
  {
      //You have to get values for below items from azure
      string accountName = "MyAccName";
      string accountPrimaryKey = "MyKey";
      string blobContainer = "ContainerName";
      CloudStorageAccount account = new CloudStorageAccount(new StorageCredentialsAccountAndKey(accountName, accountPrimaryKey), false);
      CloudBlobClient blobClient = account.CreateCloudBlobClient();
      CloudBlobContainer container = blobClient.GetContainerReference(blobContainer);
      CloudBlob blob = container.GetBlobReference(blobName);
      MemoryStream memStream = new MemoryStream();
      blob.DownloadToStream(memStream);
  
      Response.ContentType = blob.Properties.ContentType;
      Response.AddHeader("Content-Disposition", "Attachment; filename=" + blobName.ToString());
      Response.AddHeader("Content-Length", (blob.Properties.Length - 1).ToString());
      Response.BinaryWrite(memStream.ToArray());
      Response.End();
  }
  </code></pre>