title: Rename azure blob file and Download it
body: <p>I have few files in azure blobs that are stored with unique file names and when the client wants to download, i want to rename to a friendly name.</p>
  
  <p>I'm still using 2014 azure storage dlls in my project and i'm not planning to update them anytime soon. So i can't use built-in <code>ContentDeposition</code> and rename it.</p>
  
  <p>I tried using following code in my controller:</p>
  
  <pre><code>        var blob = blobStorage.GetBlobRef("https://mysite.blob.core.windows.net/my-container/WERF3234435FFF_ERFas23E.doc");
  
          MemoryStream memStream = new MemoryStream();
          blob.DownloadToStream(memStream);
          Response.ContentType = blob.Properties.ContentType;
          Response.AddHeader("Content-Disposition", "Attachment; filename=abcd_New.doc");
          Response.AddHeader("Content-Length", blob.Properties.Length.ToString());
          Response.BinaryWrite(memStream.ToArray());
  </code></pre>
  
  <p>but its not downloading the file.</p>
  
  <p>I also tried using this:</p>
  
  <pre><code>        MemoryStream memStream = new MemoryStream();
          blob.DownloadToStream(memStream);
          System.Web.HttpContext.Current.Response.Clear();
          System.Web.HttpContext.Current.Response.ContentType = blob.Properties.ContentType;
          System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "Attachment; filename=" + friendlyName.doc);
          System.Web.HttpContext.Current.Response.AddHeader("Content-Length", blob.Properties.Length.ToString());
          System.Web.HttpContext.Current.Response.BinaryWrite(memStream.ToArray());
          System.Web.HttpContext.Current.Response.End();
  </code></pre>
  
  <p>I have my business logic in a separate solution and getting the blob reference from there to my main solution.</p>
  
  <p>Am i missing something? </p>