locked
[asp.net core 3.1 angular SPA] Authorization routes not match... RRS feed

  • Question

  • User1286808301 posted

    Hello.

    I am trying to create an asp.net core 3.1 application based on the Visual Studio Angular Model. I just reused the angular api-authorization module found in this model in my own angular SPA, but I'm having a problem with authorization routes. For example, if I try to click "Register", this request returns the following error:

    ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'Identity/Account/Register

    My application is usually the same as the template project but does not return the registry view form (or another form and view). I do not have the code of views as login and register and I do not know how to debug in this case ...

    If anyone has an idea of what could be the cause of this problem? Or a good way to debug that... ;-)

    Tuesday, October 29, 2019 3:07 AM

Answers

  • User1286808301 posted

    Ok. I have forgot the AddDefaultUI() next to AddIdentity(). It fix the routes problem.

    smile

    But the problem using addRoles() with AddDefautIdentity() relative to the github issue remains non-functional

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 30, 2019 7:44 AM

All replies

  • User1286808301 posted

    In addition to this topic, see the console log of the project when i start it and just try to access the Register link of the error: https://pastebin.com/Z6NEvev2

    I have highlighted the identity routes part with line like ##################### to show you.

    Tuesday, October 29, 2019 10:22 AM
  • User1286808301 posted

    Okay. I think I found the problem. It's because I have a small difference in StartUp.cs

    The template provided by Visual Studio has this in the ConfigureServices method in Startup.cs:

    services.AddDefaultIdentity<ApplicationUser>()
            .AddRoles<IdentityRole>()
            .AddEntityFrameworkStores<ApplicationDbContext>();

    And I have this because the roles do not work (nothing added on the AspNetUserRole database table for new users for at new user registration):

    services.AddIdentity<ApplicationUser, IdentityRole>(options =>
         {
            options.Password.RequireDigit = true;
            options.Password.RequiredLength = 6;
            options.Password.RequireNonAlphanumeric = false;
            options.Password.RequireUppercase = true;
            options.Password.RequireLowercase = true;
            options.Password.RequiredUniqueChars = 0;
            options.User.RequireUniqueEmail = true;
    //      options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-._ @+";
            options.Lockout.DefaultLockoutTimeSpan = System.TimeSpan.FromMinutes(5);
            options.Lockout.MaxFailedAccessAttempts = 5;
            options.Lockout.AllowedForNewUsers = true;
            options.SignIn.RequireConfirmedEmail = true;
            options.SignIn.RequireConfirmedPhoneNumber = false;
            options.Stores.ProtectPersonalData = false; //if true, require IProtectedUserStore implementation
    //      options.Tokens.AuthenticatorIssuer = Configuration["Jwt:Issuer"];
    //      options.Tokens.AuthenticatorTokenProvider = ;
    //      options.Tokens.ChangeEmailTokenProvider = ;
    //      options.Tokens.ChangePhoneNumberTokenProvider = ;
    //      options.Tokens.EmailConfirmationTokenProvider = ;
    //      options.Tokens.PasswordResetTokenProvider = ;
         })
         .AddEntityFrameworkStores<ApplicationDbContext>();

    You could find more information about this problem here: https://github.com/aspnet/AspNetCore.Docs/issues/14944

    Finally to explain this problem, there are also differences in the console log. (highlighted by ######...). The original template version: https://pastebin.com/qdUb55QX

    My console log version: https://pastebin.com/j8GS5G6d

    If someone have an idea about that problem and a way to fix it ;-)
    Thanks in advance.

    Tuesday, October 29, 2019 11:57 AM
  • User1286808301 posted

    Ok. I have forgot the AddDefaultUI() next to AddIdentity(). It fix the routes problem.

    smile

    But the problem using addRoles() with AddDefautIdentity() relative to the github issue remains non-functional

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 30, 2019 7:44 AM