title: The character encoding of the plain text document was not declared. in ASP.NET MVC for downloading PDF
body: <p>I have a link in MVC project that by clicking the link the PDF downloaded in the Browser, the retrieval part base on number is done by WebApi service that is returning the PDF as a byte array, in my MVC I download the PDF. </p>
  
  <p>This is working locally, even when the webAPI is is production it is working. But when I upload the project on the server, the PDF download is not working. I am not getting anything in IE and Chrome, but in Firefox I get this in console that I am not sure if that is why is not showing the PDF.</p>
  
  <blockquote>
    <p>The character encoding of the plain text document was not declared. The   document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature.</p>
  </blockquote>
  
  <p>This is my code to call the WebAPI and download the PDF in ASP.NET MVC:</p>
  
  <pre><code>    [HttpGet]
      public FileResult openPdf(string FileName, string Number)
      {
          try
          {
              string completeFileName = FileName + ".pdf";
              byte[] pdfByte = DownloadFile(completeFileName, RemoteRefNumber);
              return File(pdfByte, "application/pdf", completeFileName);
          }
          catch (Exception e)
          {
              return null;
          }
      }
  
      internal byte[] DownloadFile(string FileName, string Number)
      {
          string url = string.Empty;
  
          url = ConfigurationManager.AppSettings["RefTest"].ToString();
  
          try
          {
              string serverUrl = string.Format(url + "GetPdfName/GetPdfName?Number={0}", Number);
  
              var client = new System.Net.WebClient();
  
              client.Headers.Add("content-disposition", string.Format("inline;FileName=\"{0}\"", FileName));
  
              return client.DownloadData(serverUrl);
          }
          catch (Exception e)
          {
              return null;
          }
      }
  </code></pre>