我正在尝试将使用 Azure AD B2C 的身份验证添加到Web 表单应用程序。不幸的是,我发现的每个教程都是针对 MVC 的,除了这个 web forms tutorial。使用该教程,我已将此代码添加到我的 startup.auth.cs 中:
public partial class Startup {
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301883
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = "my-client-id",
Authority = "https://login.microsoftonline.com/my-tenant"
});
}
}
这工作正常。但是,我需要注册功能以及登录功能,但我不知道该怎么做,因为我发现的一切都是针对 MVC 的,我不知道如何将其转换为我需要的。我试过添加这样的代码:
app.UseOpenIdConnectAuthentication(CreateOptionsFromPolicy(_SignUpPolicyId));
app.UseOpenIdConnectAuthentication(CreateOptionsFromPolicy(_ProfilePolicyId));
app.UseOpenIdConnectAuthentication(CreateOptionsFromPolicy(_SignInPolicyId));
这在登录页面上创建了另外三个按钮,但是单击它们只会给出 404 错误并且没有额外信息,所以我也不知道如何使它工作,或者即使我朝着正确的方向前进. 我以前从未使用过 B2C,因此如果有人对 Web 表单有任何建议/做过此类事情,我将非常感谢一些提示或示例代码。