blazor server using AcquireTokenInteractive (msal) spins indefinitely on login when deployed on domain server

Louis Fequet 0 Reputation points
2025-11-30T01:57:42.8666667+00:00

Hi,

I have develop a blazor server app with MSAL authentication and everything works like a charm on localhost. I deployed it on the domain server, I clicked on the button login and it spins indefinitely. I'm never prompt to enter my credentials.

Note .I have added a Redirect Uri on azure https:mydomain:portnumber.

Does anyone have an idea.

Developer technologies | ASP.NET | ASP.NET Core
{count} votes

2 answers

Sort by: Most helpful
  1. Jack Dang (WICLOUD CORPORATION) 7,970 Reputation points Microsoft External Staff Moderator
    2025-12-01T04:54:54.26+00:00

    Hi @Louis Fequet ,

    Thanks for reaching out. Based on your description, here are key points to check for the “spins indefinitely” login issue in Blazor Server + MSAL + Azure AD:

    1. MSAL client type - For server-side apps, a confidential client is recommended. Using AcquireTokenInteractive as a public client may work locally but often fails when deployed. https://learn.microsoft.com/en-us/entra/msal/msal-client-applications https://learn.microsoft.com/en-us/entra/msal/dotnet/getting-started/scenarios
    2. Redirect URI - Ensure the URI in Azure AD matches your deployed domain, port, and path. A mismatch can prevent the login response from reaching your app. https://docs.azure.cn/en-us/entra/identity-platform/scenario-web-app-sign-user-app-configuration https://docs.azure.cn/en-us/entra/identity-platform/how-to-add-redirect-uri https://docs.azure.cn/en-us/entra/identity-platform/reply-url
    3. HTTPS & hosting - Redirects require HTTPS. If behind a proxy or load balancer, ensure the original scheme is forwarded correctly; otherwise login may stall.
    4. Authentication flow - In Blazor Server, rely on the standard server-side OpenID Connect flow instead of manually calling AcquireTokenInteractive.
    5. Additional info needed - Exact redirect URIs, proxy/load balancer setup, browser/server errors, and HTTPS configuration. This will help pinpoint the issue if it persists.

    Following these checks should help identify likely causes. Once you provide the details above, more specific guidance can be offered.

    Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.

    1 person found this answer helpful.
    0 comments No comments

  2. Q&A Assist
    2025-11-30T01:58:03.0433333+00:00
    AI generated content. This question contains an answer created with AI from Q&A; Assist. Learn more

    When your Blazor Server app using MSAL authentication spins indefinitely on login after being deployed on a domain server, there are a few potential issues to consider:

    1. Redirect URI Configuration: Ensure that the redirect URI you configured in Azure matches exactly what your application is using in production. The URI should include the correct domain and port number. If the app is running on a different port or domain than specified, it may cause issues.
    2. Browser Compatibility: Check if the browser being used has any restrictions or settings that might block pop-ups or redirects, especially if it is a corporate environment. Some browsers may block third-party cookies or pop-ups, which can interfere with the authentication process.
    3. Network Issues: Ensure that there are no network issues preventing the application from reaching the Azure AD endpoint. This can include firewall settings or proxy configurations that might block the requests.
    4. MSAL Configuration: Review the MSAL configuration in your application. Ensure that the PublicClientApplication is correctly set up and that the redirectUri is properly specified in the configuration.
    5. Check for Errors: Use the browser's developer tools to check for any errors in the console or network tab that might give more insight into what is happening during the authentication process.

    If these steps do not resolve the issue, you may want to consult the documentation for more specific troubleshooting steps related to MSAL and Blazor apps.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.