title: Fetch word document from an API and download it
body: <p>I have a 3rd party API. When i call that api it will output a word document.</p>
  
  <p>In my .net website i have an ASPX page. When user browse that page, i have to call that 3rd party API, get the word document and should send it to user as a downloadable word document.</p>
  
  <p><strong><em>Note:</em></strong> I cannot call that 3rd party api using javascript for security reasons.</p>
  
  <p>I tried below code</p>
  
  <pre><code>    WebClient wClient = new WebClient();
      var pagesource = wClient.DownloadString("3rd party api");
  
      Response.Clear();
      Response.AddHeader("Content-Type", "application/msword");
      Response.AddHeader("Content-Disposition", "attachment; filename=test.docx");
      Response.Write(pagesource);
      Response.End();
  </code></pre>
  
  <p>It downloads the word document. But when i open it, it is corrupted.</p>