-
Notifications
You must be signed in to change notification settings - Fork 344
WebView2
A modern embedded browser based on Microsoft Edge, capable of performing Windows Hello, log-in with FIDO keys, etc. This browser replaces the old embedded WebView, based on an outdated version of Internet Explorer.
- All Windows versions
- MSAL version 4.28.0 and higher
- WebView2 runtime must be installed on the machine
WebView2 runtime is not available on all Windows machines by default. Edge needs to be installed. Applications may choose to install it or guide the end users to install it. Installing it requires admin access.
- On .NET5-windows10.xxx, there is no change
- On .NET Classic and .NET Core 3.1, add a reference to Microsoft.Identity.Client.Desktop and call
.WithDesktopFeatures()
var pca = PublicClienntApplicationBuilder
.Create("client_id")
.WithDesktopFeatures()
.Build()
Embedded WebView | Default WebView | |
---|---|---|
.NET Fx | WebView2, fallback to Legacy | Embedded |
.NET Core | WebView2, fallback to Legacy* | Embedded |
.NET 5 | WebView2, fallback to Legacy* | Embedded |
*In .NET Core and .NET 5, fallback to legacy WebView is available starting in MSAL 4.30.0.
There's a scenario when an app that targets .NET Framework and references MSAL.NET NuGet package tries to acquire token interactively with WebView2 embedded browser, WebView2 will throw exceptions. These errors can be System.BadImageFormatException: An attempt was made to load a program with an incorrect format.
or System.DllNotFoundException: 'Unable to load DLL 'WebView2Loader.dll': The specified module could not be found.
(As of MSAL.NET 4.32.0 these exceptions are wrapped into MsalClientException
.)
This occurs because of an existing bug in the WebView2 SDK on .NET Classic platform because it can't figure out the target platform of the dependencies. One possible workaround is to add a <PlatformTarget>
with values AnyCPU
, x86
, or x64
to your app's project file. (x86
or x64
have to match the target framework of the WebView2 installed on the machine.) Another workaround is to add <PlatformTarget>AnyCPU</PlatformTarget>
in your app's project file and also directly reference WebView2 NuGet. For details, see issues #2482, #730.
- Home
- Why use MSAL.NET
- Is MSAL.NET right for me
- Scenarios
- Register your app with AAD
- Client applications
- Acquiring tokens
- MSAL samples
- Known Issues
- AcquireTokenInteractive
- WAM - the Windows broker
- .NET Core
- Maui Docs
- Custom Browser
- Applying an AAD B2C policy
- Integrated Windows Authentication for domain or AAD joined machines
- Username / Password
- Device Code Flow for devices without a Web browser
- ADFS support
- Acquiring a token for the app
- Acquiring a token on behalf of a user in Web APIs
- Acquiring a token by authorization code in Web Apps
- High Availability
- Token cache serialization
- Logging
- Exceptions in MSAL
- Provide your own Httpclient and proxy
- Extensibility Points
- Clearing the cache
- Client Credentials Multi-Tenant guidance
- Performance perspectives
- Differences between ADAL.NET and MSAL.NET Apps
- PowerShell support
- Testing apps that use MSAL
- Experimental Features
- Proof of Possession (PoP) tokens
- Using in Azure functions
- Extract info from WWW-Authenticate headers
- SPA Authorization Code