I followed all the steps here, and after switching primary key to <int>, the 'Register' and 'Login' links are not generated anymore. In my html page I have just this:
<a class="nav-link" href="">Login</a>
but the code looks like this:
<li class="nav-item"><a asp-page="/Account/Login" class="nav-link">Login</a></li>
For the page to work, I had to change the @inject statements like this:
@inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<ApplicationUser> UserManager
Anyone has an ideea why?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@hmihail routing needs a valid route to generate a link.
For the page to work, I had to change the @Inject statements like this:
So is everything working? What's the correct URI for Login?
The URI should by /Account/Login, but even if I enter in the browser that addres, I get 404:
No webpage was found for the web address: https://localhost:44305/Account/Login
Try https://localhost:44305/Identity/Account/Login
The links are not generated because you don't have a valid route. I'm not sure what you did wrong. You can probably get a quicker response on StackOverflow.
The login page doesn't use route data - so changing the PK doesn't affect routing.
I did nothing else, it was an empty project. I just followed the instructions here.
With the link https://localhost:44305/Identity/Account/Login it works.
I tried StackOverflow, but nobody answered :(
I can provide the source code if necessary.
the link
https://localhost:44305/Identity/Account/Loginworks.
That's because you're using the new 2.1 templates which use /Identity for the area. Your problem has nothing to do with changing the PK. You must have 2.0 code mixed with 2.1 code.
See

You are right, thanks for pointing that out. I have copied the LoginPartial code from somewhere, and missed the asp-area="Identity".
Thank you!
I created an ASP.NET Core 2.1 MVC app with authentication enabled using individual user accounts (store user accounts in-app), and verified that the Identity's register and login links are generated correctly:
https://localhost:XXXXX/Identity/Account/Registerhttps://localhost:XXXXX/Identity/Account/LoginI followed the steps in this doc to change the identity user and identity role primary key to Guid. But it didn't work (bug for this doc?) because I also need to update the Views/Shared/_LoginPartial.cshtml with the following:
@inject SignInManager<ApplicationUser> SignInManager@inject UserManager<ApplicationUser> UserManagerAfter that, I notice the Identity's register and login links are generated correctly. They became "unrouted":
https://localhost:XXXXX/?area=Identity&page=%2FAccount%2FRegisterhttps://localhost:XXXXX/?area=Identity&page=%2FAccount%2FLoginNot only the link are not generated correctly, the previously working URLs stopped showing the register and login page content too:
https://localhost:XXXXX/Identity/Account/Registerhttps://localhost:XXXXX/Identity/Account/LoginIs this a known issue? Any idea how I can fix this?
Thank you.
Thanks @Rick-Anderson, @scottaddie, @HaoK and @javiercn for finding the fix.
The solution is to add .AddDefaultUI() in the Startup.cs:
services.AddIdentity<ApplicationUser, ApplicationRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultUI()
.AddDefaultTokenProviders();
Note that this solution is applicable to ASP.NET Core 2.1 only, not for 2.0.
See #6967 for similar issue.
I'll be documenting this as part of https://github.com/aspnet/Docs/issues/8605
A interface do usuário da identidade é implementada usando o Razor Pages. Para que o roteamento do nó de extremidade os mapeie, adicione uma chamada MapRazorPagesno seu UseEndpointsretorno de chamada:
app.UseEndpoints(endpoints =>
{
// ...
endpoints.MapRazorPages();
});
Most helpful comment
Thanks @Rick-Anderson, @scottaddie, @HaoK and @javiercn for finding the fix.
The solution is to add
.AddDefaultUI()in the Startup.cs:Note that this solution is applicable to ASP.NET Core 2.1 only, not for 2.0.
See #6967 for similar issue.