title: ASP.NET MVC file download and jQuery parameter
body: <p>I have a (ViewResult) Controller which receives a string parameter, generates a PDF file, and sends the PDF file back to the browser. I’ve tested the controller itself, and it works fine. Unfortunately, when I try to post to this controller from the $.ajax jQuery function (passing a simple string), the Controller <em>always</em> receives the string parameter as null. I've tried a hundred different configurations of the $.ajax function. Here's the controller, which returns a PDF to the browser (it works...as long as I create the HTML within the method):</p>
  
  <pre><code>[HttpPost]
  public ActionResult HtmlToPdf(String htmlData)
  { }
  </code></pre>
  
  <p>Here's the jQuery I'm using in my view (triggered by a button click):</p>
  
  <pre><code>function getPdf() {
      var htmlData = “blah, blah, etc.”;
      $.ajax({
          url: '/Home/HtmlToPdf',
          type: 'post',
          data: JSON.stringify(htmlData),
          contentType: 'application/json; charset=utf-8',
          success: handleSuccess,
          error: handleError
      });
  }
  </code></pre>
  
  <p>I've tried 'post', 'get', json, text, html, stringify, different content types, etc. Does anyone know how to correctly send a string (the var 'htmlData' above) to a controller? Post? Get? Something else? Thanks.</p>