第一步:在您的项目中导入 Microsoft.AspNetCore.Authentication.OpenIdConnect 包。 第二步:打开 Startup.cs 文件并在 ConfigureServices 方法中添加以下代码:
services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie(options =>
{
options.LoginPath = "/Account/Login/";
})
.AddOpenIdConnect(options =>
{
options.Authority = "https://login.microsoftonline.com/common/v2.0/";
options.ClientId = "
注:将上述代码中的
这样,您的 Blazor WASM ASP.NET Core hosted with Identity 项目就可以在部署时正常工作了。