Migrating from Forms Authentication to Azure ADB2C

Shereen Fathima 0 Reputation points
2025-07-03T02:20:59.2433333+00:00

We are currently in the process of transitioning from forms authentication to Azure AD B2C (ADB2C). Our web application is developed using the MVC C# framework and .NET Standard. We have successfully integrated ADB2C login into the application utilising OWIN; however, we seek further clarification to ensure we proceed correctly with this implementation. (Our primary objective is to incrementally upgrade our web application to .NET Core. For the time being, we are focused on integrating ADB2C into the existing MVC application, with plans to migrate to .NET Core in the future.)

 

During our integration with OWIN, we have encountered challenges in obtaining the access token during the OpenID Connect authorization code receive event. Our preliminary research indicates that the access token may not be necessary for the login process. Additionally, we have effectively utilised the Graph API to update and create user accounts while correctly acquiring the endpoint. We would appreciate your insight on whether this approach is suitable for a .NET MVC application.

In addition, our research has revealed that MSAL (Microsoft Authentication Library) is capable of managing access tokens and session expiry. We would like to understand whether MSAL can be effectively utilised in a standard .NET MVC application or if it is preferable to continue utilising OWIN.

 

Finally, we are currently implementing custom claims; however, we have noticed that the middleware is rewrapping these claims with each request. We have concerns that our reliance on custom claims may lead to complications in the future.

Microsoft Security | Microsoft Entra | Microsoft Entra External ID
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Doaa Ali Hamdan AL-Jarwani 340 Reputation points
    2025-07-03T07:10:46.4866667+00:00

    Hi Shereen,

    You’re on the right track using OWIN with Azure AD B2C in your MVC app.

    Here are a few quick points:

    • Access token isn’t needed just for login — it’s only required if you plan to call APIs like Microsoft Graph.
    • OWIN works fine for basic auth flows, but if you need access tokens and better session handling, MSAL is more flexible and future-proof — especially if you’re planning to move to .NET Core.
    • Regarding custom claims, if they’re being reset or rewrapped each time, you might want to persist them separately or adjust your middleware logic. Too much reliance on custom claims can get tricky over time.

    Hope this helps!


Your answer

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