title: Display PDF on new tab after ajax call MVC C#
body: <p>I am new at C# and I want to display a newly and dynamically created PDF to the web browser client side, on a new tab, using HttpResponseMessage.</p>
  
  <p>The PDF created is valid.
  This is my controller code :</p>
  
  <pre><code>    [HttpGet]
      public HttpResponseMessage ShowPDF()
      {
  
          MemoryStream ms = new GetPDF();
          Byte[] bytes = ms.GetBuffer();
  
          HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
          Response.AppendHeader("Content-Disposition", "inline; filename=test.pdf");
  
          result.Content = new StreamContent(ms);
          result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
  
          return result;
      }
  </code></pre>
  
  <p>After clicking on button on HTML page, nothing is happening, no error but no new pdf displayed too. I tried using both MemoryStream or Buffer, but nothing seems to work.</p>
  
  <p>EDIT </p>
  
  <p>Here is my view code :</p>
  
  <pre><code>        &lt;button id="GetPDF" class="btn btn-primary pull-right"&gt;GET PDF&lt;/button&gt;
  </code></pre>
  
  <p>Javascript :</p>
  
  <pre><code>    $('#GetPDF').click(function (e) {
          e.preventDefault();
          $.ajax({
              url: '@Url.Action("ShowPDF", "Controller")',
              method: 'GET',
              success: function (data, textStatus, jqXHR) {
               //Showing something but what
              },
              error: function ( jqXHR, textStatus, errorThrown ) {
               //Showing error message
              }
          });
      });
  </code></pre>