使用模板中的services.AddSignInConfiguration,“ AzureAdB2C”时,“ IServiceCollection”不包含“ AddSignIn”的定义

问题描述

我从AzureAD/microsoft-identity-web运行了Razor Pages的模板:

dotnet new webapp2 --auth IndividualB2C

使用哪个创建了项目

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddSignIn(Configuration,"AzureAdB2C");
        services.AddRazorPages()
                .AddMicrosoftIdentityUI();
    }

但是我查看了.csproj文件并看到:

  <ItemGroup>
    <packagereference Include="Microsoft.Identity.Web" Version="0.1.2-preview"/>
    <packagereference Include="Microsoft.Identity.Web.UI" Version="0.1.2-preview"/>
  </ItemGroup>

所以我升级了它们,因为它看起来像Microsoft.Identity.Web was GA'd at 1.0.0的新版本。现在一行:

services.AddSignIn(Configuration,"AzureAdB2C");

出现此错误

“ IServiceCollection”不包含“ AddSignIn”的定义,找不到可以接受的扩展方法“ AddSignIn”,它接受类型为“ IServiceCollection”的第一个参数(您是否缺少using指令或程序集引用?)>

解决方法

services.AddSignIn()Microsoft.Identity.Web之前的版本0.1.5 Preview的nuget包中可用,以上版本不包含services.AddSignIn()

请通过Microsoft.Identity.Web的{​​{3}}。

在当前版本1.1.0中,您可以将services.AddSignIn()替换为services.AddMicrosoftIdentityWebAppAuthentication()