Download file by POST ajax call
<p>I have an Asp.Net MVC project and in my View this stretch:</p>

<pre><code>$.ajax({
        beforeSend: function () {
            LoadStart();
        },
        complete: function () {
            LoadStop();
        },
        //async: false,
        contentType: 'application/json, charset=utf-8',
        dataType: 'json',
        type: 'POST',
        url: '@Url.Action("MyAction", "MyController")',
        data: JSON.stringify(
            {
                Param1: 1,
                Param2: 2
            }),
        success: function (data) {
            $("#pdf-content").show();
            // Here, fill DIV (pdf-content) with PDF.
        },
        fail: function () {
            alert("Fail");
        }
});
</code></pre>

<p><br/>
In <code>MyAction</code>, I have:</p>

<pre><code>[HttpPost]
public ActionResult MyAction(int Param1, int Param2)
{
    // Code ...

    MemoryStream stream = new MemoryStream();
    outPdf.Save(stream);
    byte[] fileContents = stream.ToArray();

    return File(fileContents, "application/pdf", "myFile.pdf");
}
</code></pre>

<p><br/>
How can I display the PDF in DIV, or even download directly without displaying?</p>