title: Why Request.Headers["X-PJAX"] is always empty when implementing pjax in asp.net core?
body: <p>I am trying to implement pjax in asp.net core but <code>Request.Headers["X-PJAX"]</code> is always empty. PJAX docs are - <a href="https://github.com/defunkt/jquery-pjax" rel="nofollow noreferrer">https://github.com/defunkt/jquery-pjax</a></p>
  
  <p>My _Layout.cs html code:</p>
  
  <pre><code>&lt;head&gt;
  &lt;script src="https://code.jquery.com/jquery-3.3.1.min.js"&gt;&lt;/script&gt;
  &lt;script src="~/js/jquery.pjax.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      $(function () {
          // pjax
          $('ul a').pjax('#main')
      })
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href="/" class="current"&gt;MAIN PAGE&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="/Home/About"&gt;About&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;div id="main"&gt;@RenderBody()&lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>My _ViewStart.cshtml page code:</p>
  
  <pre><code>@{
      if (ViewBag.PJAX==true)
      {
          Layout = "~/Views/Shared/_Layout.cshtml";
      }
      else
      {
          Layout = "~/Views/Shared/_Layout.cshtml";
      }
  }
  </code></pre>
  
  <p>MY controller's index and about action:</p>
  
  <pre><code>public IActionResult Index()
      {
          if (string.IsNullOrEmpty(Request.Headers["X-PJAX"]))
              ViewBag.PJAX = false;
          else
              ViewBag.PJAX = true;
          return View();
      }
  
  public IActionResult About()
      {
          if (string.IsNullOrEmpty(Request.Headers["X-PJAX"]))
              ViewBag.PJAX = false;
          else
              ViewBag.PJAX = true;
          return View();
      }
  </code></pre>
  
  <p>The problem is I get <code>Request.Headers["X-PJAX"]</code> always ""? Why???</p>
  
  <p>Please help. 
  Thank you</p>