title: Download File with Jquery Ajax
body: <p>I am using jquery Ajax for downloading PDF file, I generate PDF on runtime and download it, 
  This is my Ajax call</p>
  
  <pre><code>  $.ajax({
              async: "false",
              type: "POST",
              url: "/Reports/DownloadFile?userId=" + encodeURIComponent(userId) + "&amp;date=" + encodeURIComponent(date),
              success: function (result) {
              }
          });
  </code></pre>
  
  <p>and this is what I am doing in ActionResult</p>
  
  <pre><code> public FileContentResult DownloadFile(int userId, string date, int rptType)
          {
              var userInfo = UserBLL.GetUserByID(associateId).Name;
              var dtFileDate = Convert.ToDateTime(date);
              var pdfStream = GeneratePDFStream(userId, date);//Generating Stream
  
  if(date &lt; DateTime.Now)
  {       
  return File(pdfStream, "application/pdf", string.Format("MyReport{0}{1}.pdf", userInfo.Name, dtFileDate.ToShortDateString().Replace("/", "")));
  }
  return null; 
          }
  </code></pre>
  
  <p>but its returning </p>
  
  <pre><code>Sorry, an error occurred while processing your request.
  </code></pre>
  
  <p>How can I download the file with Ajax call? Please note that I can't use jquery FileDownload but I can do without Ajax call, Kindly suggest
  I also tried with this,but same error</p>
  
  <pre><code> var url = "/Reports/DownloadFile?userId=" + encodeURIComponent(userId) + "&amp;date=" + encodeURIComponent(date);
  
          window.open(url);
  </code></pre>