title: Can't get the header value from HTTP header in Asp.Net Core 2.0
body: <p>I have an MVC controller that aims to read the user's info from HTTP header. The header contains user info that returns from a single sign on (SiteMinder). SiteMinder redirects the user to the company login page and returns back to my app along with cookie and HTTP header. The HTTP header contains user's info. My controller is supposed to get those info and display it in the navigation bar.</p>
  
  <p>Here is the controller code:</p>
  
  <pre><code>[HttpGet]
  public async Task&lt;IActionResult&gt; GetUser()
  {
      var person = Request.Headers["HTTP_JHED_UID"].ToString();
      if (repository.GetJhedUser(person) != null)
      {
          var user = await repository.GetUser(person);
          var userDto = mapper.Map&lt;User, UserForDisplayDto&gt;(user);
          return Ok(userDto);
      }
      else
      {
          return null;
      }
  
  }
  </code></pre>
  
  <p>And here is my corresponded repository:</p>
  
  <pre><code>public string GetJhedUser(string value)
  {
      return context.Users.Where(x =&gt; x.JHED_ID == value).ToString();
  }
  
  public async Task&lt;User&gt; GetUser(string id, bool includeRelated = true)
  {
      if(!includeRelated)
          return await context.Users.FindAsync(id);
  
      return await context.Users
          .SingleOrDefaultAsync(s =&gt; s.JHED_ID == id);
  }
  </code></pre>
  
  <p>I receive 500 server error. I am sure that the header has those values. </p>
  
  <p>EDIT: Here is an image of debugging. Even I tried with "Date" the value is nothing. Please note that I refactored my codes to @Nkosi's code below</p>
  
  <p><a href="https://i.stack.imgur.com/y4emH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y4emH.png" alt="enter image description here"></a></p>
  
  <p>How to get those user's info (in this case just username) from header so that I can display in my HTML template?</p>