title: Return File from Web API in Angular 5
body: <p>I am returning a file from web API</p>
  
  <pre><code> [HttpGet("[action]")]
      public FileResult DownloadExcel()
      {
          return File($"~/files/Input.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Input.xlsx");
      }
  </code></pre>
  
  <p>Which is working perfectly </p>
  
  <p>Now I want to use it in angular on button click </p>
  
  <p>So I found some code on internet </p>
  
  <pre><code>downloadFile() {
  return this.http.get(this.baseUrl + 'api/Common/DownloadExcel/', { responseType: 'blob' })
  .map(res =&gt; {
    return {
      filename: 'filename.xlsx',
      data: res.blob()
    };
  }).subscribe(res =&gt; {
    console.log('start download:',res);
    var url = window.URL.createObjectURL(res.data);
    var a = document.createElement('a');
    document.body.appendChild(a);
    a.setAttribute('style', 'display: none');
    a.href = url;
    a.download = res.filename;
    a.click();
    window.URL.revokeObjectURL(url);
    a.remove(); // remove the element
  }, error =&gt; {
    console.log('download error:', JSON.stringify(error));
  }, () =&gt; {
    console.log('Completed file download.')
  });
  </code></pre>
  
  <p>}</p>
  
  <p>But is give error </p>
  
  <blockquote>
    <p>Property blob does not exist on type 'Blob'</p>
  </blockquote>
  
  <p>In below Line </p>
  
  <pre><code> data: res.blob()
  </code></pre>
  
  <p>I have imported </p>
  
  <pre><code>import 'rxjs/add/operator/filter';
  import 'rxjs/add/operator/mergeMap';
  import 'rxjs/add/operator/do';
  import 'rxjs/add/operator/map'
  </code></pre>
  
  <p>What I am missing here ? and is this code right ?</p>