title: get Cookies for mainpage
body: <p>I need to show application name from Cookies on _Layout.cshtml.</p>
  <pre><code>public class UserSetter : IUserSetter
  {
      public async Task SetUser(Microsoft.AspNetCore.Http.HttpContext Context)
      {
          if (!Context.Request.Cookies.ContainsKey(&quot;BaseName&quot;))
          {
              Context.Response.Cookies.Append(&quot;BaseName&quot;, &quot;MyTestBase&quot;);
          }
      }
  }
  
  public void ConfigureServices(IServiceCollection services)
          {
              services
                  .AddRazorPages()
                  .AddJsonOptions(options =&gt; options.JsonSerializerOptions.PropertyNamingPolicy = null);
  
              services.AddHttpContextAccessor();
              services.AddSingleton&lt;IUserSetter, UserSetter&gt;();
          }
  
  public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IUserSetter usr)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseExceptionHandler(&quot;/Error&quot;);
              }
  
              app.UseStaticFiles();
  
              app.UseRouting();
  
              app.UseAuthorization();
  
              app.Use(async (context, next) =&gt;
              {
                  await usr.SetUser(context);
  
                  await next();
              });
  
              app.UseEndpoints(endpoints =&gt; {
                  endpoints.MapControllers();
                  endpoints.MapDefaultControllerRoute();
                  endpoints.MapRazorPages();
              });
          }
  </code></pre>
  <p>and i need to show BaseName from cookies on _Layout.cshtml</p>
  <pre><code>&lt;div class=&quot;layout-header&quot;&gt;
      @(Html.DevExtreme().Toolbar()
          .Items(items =&gt; {
              items.Add()
                  .Widget(w =&gt; w
                      .Button()
                      .Icon(&quot;menu&quot;)
                      .OnClick(&quot;DevExtremeAspNetCoreApp3.onMenuButtonClick&quot;)
                  )
                  .Location(ToolbarItemLocation.Before)
                  .CssClass(&quot;menu-button&quot;);
              items.Add()
                  .Html(@String.Format(&quot;&lt;div&gt;DevExtremeAspNetCoreApp3 {0}&lt;/div&gt;&quot;, @Helpers.GetBaseName(Context.Request.Cookies)))
                  .Location(ToolbarItemLocation.Before)
                  .CssClass(&quot;header-title&quot;);
          })
      )
  &lt;/div&gt;
  </code></pre>
  <p>But <strong>BaseName</strong> not shows after application start. It show only when i go to some page.</p>
  <p>video <a href="https://www.screencast.com/t/o7gsv7xB" rel="nofollow noreferrer">https://www.screencast.com/t/o7gsv7xB</a></p>
  <p>Maybe someone knows how to solve this problem?</p>