c# - 在 Blazor 应用程序中使用 Azure Active Directory 时如何在

既然 AzureAD/Account 已集成到 ASP.NET Core 3.1 中,那么如何自定义用户在使用 Azure AD 身份验证从 Blazor 应用程序注销后最终到达的页面?

重现步骤:

  1. 使用 Azure 身份验证在服务器应用程序上创建新的 Blazor
  2. 点击“退出”(例如 https://localhost:44320/AzureAD/Account/SignOut)链接
  3. 用户最终进入“退出”页面(例如 https://localhost:44320/AzureAD/Account/SignedOut)

我已经尝试搭建身份登录和注销页面的脚手架,但这没有帮助。

最佳答案

好吧,我已经接近搭建身份的脚手架了。

看到我检查了帐户\登录 和帐户\注销

然后我从 Areas\AzureAD\Pages\Account 中删除了 Account\Login 并将 Logout.cshtml 重命名为 SignedOut.cshtml

我还删除了 Areas\Identity\Data 文件夹,因为我不需要它。

我遇到的另一个问题是 ConfigureServices 正在添加不需要的 ControllersWithViews()。

public void ConfigureServices(IServiceCollection services)
    {
        services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
            .AddAzureAD(options => Configuration.Bind("AzureAd", options));

        //services.AddControllersWithViews(options =>
        //{
        //    var policy = new AuthorizationPolicyBuilder()
        //        .RequireAuthenticatedUser()
        //        .Build();
        //    options.Filters.Add(new AuthorizeFilter(policy));
        //});

        //services.AddMvc();
        services.AddRazorPages();
        services.AddServerSideBlazor();
        services.AddSingleton<WeatherForecastService>();
    }

关于c# - 在 Blazor 应用程序中使用 Azure Active Directory 时如何在 asp net core 3.1 中自定义注销页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59884125/

相关文章:

vagrant 2.2.7 - 无法 vagrant up : default: Warning:

android - 尝试在使用谷歌驱动器的 android 应用程序(使用 kotlin)webvi

microsoft-graph-api - 带有过滤器的 microsoft-graph api 用

google-bigquery - 如何在 Google BigQuery 中将日期解析为周年?

go - sqlx 无法对嵌套结构使用结构扫描

kubernetes - 从一组副本中选择一个 kubernetes pod 来执行任务

reactjs - 类型 'background' 上不存在属性 '{}' - React Rout

javascript - CSS 不透明度过渡不适用于 Safari

git - 无法将 'core.repositoryformatversion' 设置为 '0'

excel - 查找工作表中的总行数和列数 - Microsoft Graph