AuthenticationBuilder does not contain a definition for AddAzureAd
Solution 1
I had the exact same loss of time with something as stupid as not adding the reference. The answer to this question would be along the lines of:
dotnet add package Microsoft.AspNetCore.Authentication.AzureAD.UI --version 2.2.0
Notice that you may have added another reference related to authentication but not the one you are having the problem about.
Solution 2
I had to add a using statement to my Startup file.
using Microsoft.AspNetCore.Authentication;
superninja
Updated on June 29, 2022Comments
-
superninja almost 2 years
Im following a tutorial from here and trying to enable OpenId Connect using Azure Ad and here's the code that I am trying to add to the Startup.cs file.
services.AddAuthentication(sharedOptions => { sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }) .AddAzureAd(options => Configuration.Bind("AzureAd", options)) .AddCookie();
But it has red underline for
AddAzureAd
and shows this error message:'AuthenticationBuilder' does not contain a definition for 'AddAzureAd' and no accessible extension method 'AddAzureAd' accepting a first argument of type 'AuthenticationBuilder' could be found (are you missing a using directive or an assembly reference?)
Steps I have tried:
- Clean and rebuild the solution
- restart visual studio
But it doesnt fix the issue. Anyone knows what's the other reason that causes this?
-
Eru over 3 yearsthis unfortunately did not help for me :(