Search code examples
asp.netasp.net-coreidentityserver4

asp.net core identity and identityserver


I'm following this walkthrough on integrating asp.net core identity with IdentityServer but have hit a few roadblocks.

Where I'm updating the ConfigureServices method, if I follow the guide and use

services.AddIdentity<IdentityUser, IdentityRole>()
        .AddEntityFrameworkStores<ApplicationDbContext>()
        .AddDefaultTokenProviders();

I can no longer access any of the account related functions. The routing for the register link changes from

~/Identity/Account/Register

to

~/?area=Identity&page=%2FAccount%2FRegister

Which breaks all account related functions

If I leave it at

services.AddDefaultIdentity<IdentityUser>()
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddDefaultTokenProviders();

Then the routing still works, I can enter my credentials via the login page and the login is successful, but

SignInManager.IsSignedIn(User)

returns false, so I'm guessing something is fundamentally broken here.

I have added identityserver to my ConfigureServices:

    services.AddIdentityServer()
                    .AddDeveloperSigningCredential()
                    .AddInMemoryPersistedGrants()
.AddInMemoryIdentityResources(Config.IdentityResources.GetIdentityResources())
                    .AddInMemoryApiResources(Config.APIResources.GetApiResources())
                    .AddInMemoryClients(Config.Clients.GetClients())
                    .AddAspNetIdentity<IdentityUser>();

Any ideas what needs to change - I'm guessing its something in the latest version of asp.net core that has caused this has it?


Solution

  • Figured this out in the end. Seems like a weird bug as MSFT migrates to Razor pages. All I needed to do was add in the Scaffolding UI and it just started working