B2C 太多自定义策略 link 从应用程序

B2C too many custom policies to link to from application

我有一个加入 B2C 的 Web 应用程序。有通常的自定义策略文件设置,例如:SignUpSignIn、ChangePassword 等。但是我想要更多,例如:用于具有自己的自定义策略文件的自定义注册过程。

在 .net5 razor 应用程序中,我们不再控制帐户控制器,因为这是为我们设置的。在控制器中,我们只能访问 5 个 asp 操作:Challenge、EditProfile、ResetPassword、SignIn 和 SignOut:

在这个应用程序中,我已经分配了每一个用于其他进程。因此,我如何添加另一个 'custom' asp-action,我可以使用它来调用新的自定义策略?

在对 AccountController.cs 文件进行一些调查后,我能够获取 ResetPassword 过程的代码并稍微调整一下:

var redirectUrl = $"[redirect location]";
var scheme = OpenIdConnectDefaults.AuthenticationScheme;
var properties = new AuthenticationProperties { RedirectUri = redirectUrl };
properties.Items["policy"] = "[Name of B2C Custom Policy]";

return Challenge(properties, scheme);

单击运行此代码的按钮后,我将转到上面第 4 行代码的自定义策略的 B2C 屏幕。