This repository has been archived by the owner on Jun 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 214
use async controller actions
Jean-Marc Prieur edited this page Jun 12, 2018
·
1 revision
When calling ADAL.NET in an ASP.NET or ASP.NET Core Web Application or Web API controller, you need to make sure that you use the async/await pattern and have your controller actions be async method, otherwise you'll experience multi-threading issues.
In particular you should not use .Result(). See Reminder: Do not call ADAL or MSAL async methods synchronously from the UI thread
Make sure your controller actions be async
and return Task<HttpResponseMessage>
, and then change the following line to:
var user = await authenticationContext.AcquireTokenXXXAsync()
For more information about the kind of experience you could get if you use .Result
, please see Issue #555: Cannot acquire token in web app context
- Home
- Why use ADAL.NET?
- Register your app with AAD
- AuthenticationContext
- Acquiring Tokens
- Calling a protected API
- Acquiring a token interactively
- Acquiring tokens silently
- Using Device Code Flow
- Using Embedded Webview and System Browser in ADAL.NET and MSAL.NET
- With no user
- In the name of a user
- on behalf of (Service to service calls)
- by authorization code (Web Apps)
- Use async controller actions
- Exception types
- using Broker on iOS and Android
- Logging
- Token Cache serialization
- User management
- Using ADAL with a proxy
- Authentication context in multi-tenant scenarios
- Troubleshooting MFA in a WebApp or Web API
- Provide your own HttpClient
- iOS Keychain Access