sup*_*nja 5 c# authentication azure azure-active-directory asp.net-core
我在这里遵循了一个教程,尝试使用Azure Ad启用OpenId Connect,这是我尝试添加到Startup.cs文件中的代码。
services.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddAzureAd(options => Configuration.Bind("AzureAd", options))
.AddCookie();
Run Code Online (Sandbox Code Playgroud)
但是它带有红色下划线,AddAzureAd并显示以下错误消息:
'AuthenticationBuilder'不包含'AddAzureAd'的定义,找不到可以接受的扩展方法'AddAzureAd'接受类型为'AuthenticationBuilder'的第一个参数(您是否缺少using指令或程序集引用?)
我尝试过的步骤:
但这并不能解决问题。有人知道导致此问题的另一个原因是什么吗?
我因为没有添加参考文献而感到愚蠢,却浪费了相同的时间。这个问题的答案将是:
dotnet add package Microsoft.AspNetCore.Authentication.AzureAD.UI --version 2.2.0
Run Code Online (Sandbox Code Playgroud)
请注意,您可能添加了与身份验证相关的另一参考,但没有添加您遇到问题的参考。
我有一个类似的错误,但对我来说是:
CS1061“AuthenticationBuilder”不包含“AddGoogle”的定义,并且找不到接受“AuthenticationBuilder”类型的第一个参数的可访问扩展方法“AddGoogle”(您是否缺少 using 指令或程序集引用?)
通过安装NuGet解决Microsoft.AspNetCore.Authentication.Google
https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.Google
| 归档时间: |
|
| 查看次数: |
2191 次 |
| 最近记录: |