I am trying to implement Azure Active Directory B2C on a new page that I am developing, but I get this 404 - File or directory not found error 404 - File or directory not found , trying to login from my page.
I made a tenant, registered my application, created my policies, the whole deal. I can test them from the Azure portal without much trouble. However, I followed the directions for the official manual for implementing policies on my page to no avail, I get the 404 error mentioned, as if something was missing.
I even downloaded the code posted there and it works!
I tried to compare both codes, but could not see the difference. However, I am inserting my code here, hoping that you can help me with this.
Web.config
<add key="ida:Tenant" value="PlataformaXXX.onmicrosoft.com" /> <add key="ida:ClientId" value="84d2a6e6-4cac-4c53-a5ff-XXXXXXXXXXXX" /> <add key="ida:AadInstance" value="https://login.microsoftonline.com/{0}/v2.0/.well-known/openid-configuration?p={1}" /> <add key="ida:RedirectUri" value="https://localhost:59744/" /> <add key="ida:SignUpPolicyId" value="B2C_1_Sign_Up" /> <add key="ida:SignInPolicyId" value="B2C_1_Sign_In" /> <add key="ida:UserProfilePolicyId" value="B2C_1_Edit" />
STARTUP.AUTH.CS
public partial class Startup { // App config settings private static string clientId = ConfigurationManager.AppSettings["ida:ClientId"]; private static string aadInstance = ConfigurationManager.AppSettings["ida:AadInstance"]; private static string tenant = ConfigurationManager.AppSettings["ida:Tenant"]; private static string redirectUri = ConfigurationManager.AppSettings["ida:RedirectUri"]; // B2C policy identifiers public static string SignUpPolicyId = ConfigurationManager.AppSettings["ida:SignUpPolicyId"]; public static string SignInPolicyId = ConfigurationManager.AppSettings["ida:SignInPolicyId"]; public static string ProfilePolicyId = ConfigurationManager.AppSettings["ida:UserProfilePolicyId"]; public void ConfigureAuth(IAppBuilder app) { app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); app.UseCookieAuthentication(new CookieAuthenticationOptions()); // Configure OpenID Connect middleware for each policy app.UseOpenIdConnectAuthentication(CreateOptionsFromPolicy(SignUpPolicyId)); app.UseOpenIdConnectAuthentication(CreateOptionsFromPolicy(ProfilePolicyId)); app.UseOpenIdConnectAuthentication(CreateOptionsFromPolicy(SignInPolicyId)); } ...
If you need any other piece of code, please let me know.
Really guys, any help would be much appreciated.
Best regards, Toño.
source share