Profile menu not showing up anymore after scaffolding
I have create an MVC project with authorization.
Then I followed "Create full identity UI source" instructions from this page.
I updated ConfigureServices as mentioned in a previous comment I posted earlier (to avoid NotSupportedException: No IUserTwoFactorTokenProvider<TUser> named 'Default' is registered.):
services.AddIdentity<IdentityUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
I started the app
I registered a user
When I go to https://localhost:<port_number>/Identity/Account/Manage, the left menu containing 'Profile, Password, Two Factor Authentication and Personal data' is no more there (It's showing up before scaffolding)
I was expecting to have exactly the same behavior in the app if I scaffold full or not.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 804e24dd-7e30-8cf5-2c99-1ffacb4582f6
- Version Independent ID: 3e25547b-e2c9-6634-2c38-2a77207f17d4
- Content: Scaffold Identity in ASP.NET Core projects
- Content Source: aspnetcore/security/authentication/scaffold-identity.md
- Product: aspnet-core
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande
It's still there. I'm not sure what you did wrong. Did you tap the user-name link?
@Yanal-Yves see #8440
did you follow the VS or CLI instructions. I think the CLI instructions need to specify the layout file. From dotnet aspnet-codegenerator identity -h
--layout|-l : Specify a custom layout file to use.
@Rick-Anderson, I followed VS instruction and I don't remember what version of VS2017 I was using.
I have tried again today (I have update Visual Studio since the day I posted this issue). I am now using VS15.8.2 and I cannot reproduce the issue anymore.
I guess, you can simply close that issue.
Thank you for your support
@Yanal-Yves thanks for the confirmation. I can't reproduce the problem using Visual Studio 15.8 either. There might be 3 ways to get the wrong layout:
- An older version of VS (or more likely .NET Core SDK)
- Not specifying your layout file in the VS scaffolding diaglog
- Not specifying your layout file in CLI command (The instructions currently don't specify layout)
Reason for this issue.
While using AddDefaultIdentity, system will dynamically generate the required _Layout & _ViewStart pages. But when we used AddIdentity system will not allow to add the dynamic pages during the run time. So we need to manually create all the required layout pages.
Solution for this issue.
-
Create one _ViewStart.cshtml in Identity/Pages/Account/Manage(If not exists)
@{ Layout = "_Layout"; }
-
Identity/Pages/Account/Manage/_Layout.cshtml having like "Layout = "/Areas/Identity/Pages/_Layout.cshtml";" we need to change this line like Layout = "/Pages/Shared/_Layout.cshtml";. Because _Layout.cshtml file doesn't have in the "/Areas/Identity/Pages/" folder.
Notes: Based on your folder structure this _Layout.cshtml will be available on "Views/Shared/_Layout.cshtml"
-
Compile and Run the solution and test it. If its not cleared then follow the below steps also.
-
Create one _ViewStart.cshtml in Identity/Pages folder(If not exists)
@{ Layout = "_Layout"; }
-
Create one _layout.csthml in Identity/Pages folder(If not exists)
@{ Layout = "/Pages/Shared/_Layout.cshtml"; }
Notes: Based on your folder structure this _Layout.cshtml will be available on "Views/Shared/_Layout.cshtml"
- Now compile and run your solutions.
Happy Coding!!!.