Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stay logged in during development of a Blazor Web Assembly app that uses Azure AD B2C for authentication

I am developing a Blazor Web Assembly app in Visual Studio that uses Azure AD B2C for authentication. It is all setup and working well except that developing is a chore because each time I want to launch the debugger and open the browser to review my work I am required to login in again to view pages that require authentication. This is a time consuming and annoying step that I would hope to avoid.

Ideally there would be a way to stay logged in between debug browser sessions launched from Visual Studio.

I have searched for the answer on the web with not luck yet. Anyone have any ideas on how to do this?

like image 766
Andrew Hawes Avatar asked Oct 16 '25 03:10

Andrew Hawes


1 Answers

In Program.cs, set MsalCacheOptions.CacheLocation to "localStorage"

Example:

    builder.Services.AddMsalAuthentication(options =>
    {
        // Keeps logged in between debugging sessions
        options.ProviderOptions.Cache.CacheLocation = "localStorage";

        // Set up other options
        ...
    });
like image 200
Andrew Rondeau Avatar answered Oct 18 '25 22:10

Andrew Rondeau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!