title: Blazor Server + Azure B2C Identity - Change Cookie Name
body: <p>When creating a stock Blazor Server app (File/New) with Authentication for B2C you get a <code>Startup.cs</code> that looks like the following.</p>
  
  <p>B2C itself is working, but I'm trying to simply change the Cookie name. By default it appears to be (<code>.AspNetCore.AzureADB2CCookie</code>)</p>
  
  <p>How can I change it?</p>
  
  <p>I've tried the following which doesn't appear to work:</p>
  
  <p>1)</p>
  
  <pre><code>        services.ConfigureApplicationCookie(options =&gt;
          {
              options.Cookie.Name = UIConstants.WebSessionCookieName;
          });
  </code></pre>
  
  <p>2) </p>
  
  <pre><code>        .AddCookie(x =&gt;
          {
              x.Cookie.Name = UIConstants.WebSessionCookieName;
          });
  </code></pre>
  
  <p>Startup.cs</p>
  
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          services.AddAuthentication(AzureADB2CDefaults.AuthenticationScheme)
              .AddAzureADB2C(options =&gt; Configuration.Bind("AzureAdB2C", options));
  
          services.AddRazorPages();
          services.AddServerSideBlazor();
          services.AddSingleton&lt;WeatherForecastService&gt;();
  
          services.AddHttpContextAccessor();
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
          else
          {
              app.UseExceptionHandler("/Error");
              // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
              app.UseHsts();
          }
  
          app.UseHttpsRedirection();
          app.UseStaticFiles();
  
          app.UseRouting();
  
          app.UseAuthentication();
          app.UseAuthorization();
  
          app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapControllers();
              endpoints.MapBlazorHub();
              endpoints.MapFallbackToPage("/_Host");
          });
      }
  </code></pre>