I am creating a website using ASP.Net Core, and securing it with Azure AD B2C.
I have already implemented signing in and it is all working fine, but now I am attempting to setup sign up and it doesn't seem to be working.
My website setup is based on this sample .
In that example they do not use a sign up policy as they use a shared signup and signin policy (which I would prefer not to), but they do use an edit profile and reset password policy, the API methods can be seen on the SessionController .
I am trying to implement my signup endpoint in the same way like so:
var properties = new AuthenticationProperties() { RedirectUri = "/" };
properties.Items[AzureAdB2COptions.PolicyAuthenticationProperty] = AzureAdB2COptions.SignUpPolicyId;
await HttpContext.Authentication.ChallengeAsync( OpenIdConnectDefaults.AuthenticationScheme, properties, ChallengeBehavior.Unauthorized);
However, when I go here I simply get redirected to the sign in page instead of the sign up page.
The sign up policy and the B2C directory in general is setup correctly as I am using it on another site with no issues.
Can anyone advise what may be causing this?
In my OnRedirectToIdentityProvider method I had:
context.ProtocolMessage.IssuerAddress = context.ProtocolMessage.IssuerAddress.Replace(defaultPolicy, policy);
As the IssuerAddress here is lower case it wasnt finding and changing the policy.
I updated it to:
context.ProtocolMessage.IssuerAddress = context.ProtocolMessage.IssuerAddress.ToLower().Replace(defaultPolicy.ToLower(), policy.ToLower());
As is in the latest version of the sample
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.