title: HttpContext.Current.Features.Get<IRequestCultureFeature>() is null in asp.net Core
body: <p>I am trying to get the current culture from a user class in ASP.NET Core 1.1.</p>
  
  <p>I have the following under <code>ConfigureServices</code> in <em>Startup.cs</em>:</p>
  
  <pre class="lang-cs prettyprint-override"><code>services.AddSingleton&lt;IHttpContextAccessor, HttpContextAccessor&gt;();
  services.Configure&lt;RequestLocalizationOptions&gt;(options =&gt;
  {
      var supportedCultures = new List&lt;CultureInfo&gt;
      {
          new CultureInfo("en-US"),
          new CultureInfo("fil-PH")
      };
  
      options.DefaultRequestCulture = new RequestCulture(culture: "en-US", uiCulture: "en-US");
      options.SupportedCultures = supportedCultures;
      options.SupportedUICultures = supportedCultures;
  });
  </code></pre>
  
  <p>I have the following under <code>Configure</code> in <em>Startup.cs</em>:</p>
  
  <pre class="lang-cs prettyprint-override"><code>IHttpContextAccessor httpContextAccessor = app.ApplicationServices.GetRequiredService&lt;IHttpContextAccessor&gt;();
  Extensions.Context.Configure(httpContextAccessor);
  
  IOptions&lt;RequestLocalizationOptions&gt;  localizationOptions = app.ApplicationServices.GetService&lt;IOptions&lt;RequestLocalizationOptions&gt;&gt;();
  app.UseRequestLocalization(localizationOptions.Value);
  </code></pre>
  
  <p>I have the following user class:</p>
  
  <pre class="lang-cs prettyprint-override"><code>using Microsoft.AspNetCore.Http;
  using Microsoft.AspNetCore.Http.Features;
  using Microsoft.AspNetCore.Localization;
  using System;
  using System.Globalization;
  
  namespace Framework.Extensions
  {
      public class Context
      {
          public HttpContext Current { get; set; }
          public Uri AbsoluteUri { get; set; }
          public string AbsolutePath { get; set; }
          public string Url { get; set; }
          public CultureInfo Culture { get; set; }
  
          private static IHttpContextAccessor HttpContextAccessor;
          public static void Configure(IHttpContextAccessor httpContextAccessor)
          {
              HttpContextAccessor = httpContextAccessor;
          }
  
          public Context()
          {
              Current = HttpContextAccessor.HttpContext;
              AbsoluteUri = GetAbsoluteUri();
              AbsolutePath = GetAbsoluteUri().AbsolutePath;
              Url = GetAbsoluteUri().ToString();
              Culture = GetCultureInfo();
          }
  
          private Uri GetAbsoluteUri()
          {
              UriBuilder uriBuilder = new UriBuilder();
              uriBuilder.Scheme = Current.Request.Scheme;
              uriBuilder.Host = Current.Request.Host.Host.ToString();
              if (Current.Request.Host.Port != null)
              {
                  uriBuilder.Port = Current.Request.Host.Port ?? default(int);
              }
              uriBuilder.Path = Current.Request.Path.ToString();
              uriBuilder.Query = Current.Request.QueryString.ToString();
              Uri absoluteUri = uriBuilder.Uri;
              return uriBuilder.Uri;
          }
  
          private CultureInfo GetCultureInfo() {
              IFeatureCollection requestFeatures = Current.Features; /* POPULATED */
              RequestCultureFeature requestCultureFeature = requestFeatures.Get&lt;RequestCultureFeature&gt;(); /* NULL */
              RequestCulture requestCulture = requestCultureFeature.RequestCulture;
              return requestCulture.Culture;
          }
      }
  }
  </code></pre>
  
  <p>Looking at the <code>GetCultureInfo()</code> method, <strong><code>Current</code> appears to be correctly populated</strong> with info as I can see things like the host and port, etc.   <code>Features</code> is also populated - at least not null.   But calling <code>Get&lt;RequestCultureFeature&gt;()</code> on the Features is null?</p>
  
  <p>Any ideas at why this would be empty, and how to fix it?</p>
  
  <p>The reason I am trying to access it is to get the CurrentUICulture.</p>