A cloud-based identity and access management service for securing user authentication and resource access
Microsoft Graph with Web Forms
I am trying to add MSAL azure AD single tenant authentication to my existing ASPNET WebForms application. I followed
https://learn.microsoft.com/en-us/learn/modules/msgraph-build-aspnetmvc-apps/5-exercise-add-auth
I created a ASP.NET Web Application (WebForms, MVC, Web API) and followed the above article. When I use MVC as created by this article it works just fine. I am able to login and see my name and mail with signout link.
If I disable Routing to MVC default Home(created with above example), and let WebForms default.aspx page loads, it loads fine. but when I click login (it is coded to signin from master page link), I am getting login page of OpenID connect.
When I signin the OnAuthorizationCodeReceivedAsync method, throws an error in this line.
var result = await idClient.AcquireTokenByAuthorizationCode(
scopes, notification.Code).ExecuteAsync();
BeforeAccessNotification, AfterAccessNotification methods throw Object reference not set exception for
httpContext.Session[tokenCacheKey], while userId based tokenCacheKey value is available in variable. httpcontext is HttpContext.Current is null.
How to resolve this error.