title: Return PDF to the Browser using ASP.NET Core
body: <p>I created the Wep API in ASP.Net core to return the PDF. Here is my code:</p>
  
  <pre><code>public HttpResponseMessage Get(int id)
  {
      var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK);           
      var stream = new System.IO.FileStream(@"C:\Users\shoba_eswar\Documents\REquest.pdf", System.IO.FileMode.Open);
      response.Content = new StreamContent(stream);
      response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
      response.Content.Headers.ContentDisposition.FileName = "NewTab";
      response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");
      return response;
  }
  </code></pre>
  
  <p>But it returns only the JSON response:</p>
  
  <pre><code>{
     "version":{
        "major":1,
        "minor":1,
        "build":-1,
        "revision":-1,
        "majorRevision":-1,
        "minorRevision":-1
     },
     "content":{
        "headers":[
           {
              "key":"Content-Disposition",
              "value":[
                 "attachment; filename=NewTab"
              ]
           },
           {
              "key":"Content-Type",
              "value":[
                 "application/pdf"
              ]
           }
        ]
     },
     "statusCode":200,
     "reasonPhrase":"OK",
     "headers":[
  
     ],
     "requestMessage":null,
     "isSuccessStatusCode":true
  }
  </code></pre>
  
  <p>Am I doing anything wrong here?</p>