Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

ASP.NET Core Auth not staying signed in after browser closes (Azure AD B2C)

$
0
0

I've successful set up authentication with Azure AD B2C in my ASP.NET Core Blazor application. I can open the website (https://localhost:5001) in multiple tabs without signing in again. However, if I keep the server running but close and reopen the browser and navigate to the website, it requires me to sign in again. My understanding was that it should have kept me signed in between browser sessions. I'm fairly new to all this, so I'm not even sure where to begin looking for the problem. Any ideas what this might be?

Here is my Startup.cs, if it helps.

public class Startup{    private IConfiguration Configuration { get; }    public Startup(IConfiguration configuration) => Configuration = configuration;    // This method gets called by the runtime. Use this method to add services to the container.    // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940    public void ConfigureServices(IServiceCollection services)    {        services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)            .AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAdB2C"));        services.AddControllersWithViews().AddMicrosoftIdentityUI();        services.AddAuthorization(options =>        {            // By default, all incoming requests will be authorized according to the default policy            options.FallbackPolicy = options.DefaultPolicy;        });        services.AddRazorPages();        services.AddServerSideBlazor().AddMicrosoftIdentityConsentHandler();    }    // 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 =>        {            endpoints.MapControllers();            endpoints.MapBlazorHub();            endpoints.MapFallbackToPage("/_Host");        });    }

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>