Account Management navigation missing after scaffolding the Identity UI
This is basically a duplicate of Issue #7827, I would reopen it if I knew how. To recreate the issue:
EDIT by @Rick-Anderson OK, after much mucking around I have found the following:
- Specifying the layout file in the scaffolding dialog doesn't seem to do anything. I have only made a cursory check of this.
- To get the navigation working you need to do two things after running the scaffolding:
- Add a _viewstart.cshtml to the Manage folder to set the layout
@{
Layout = "_Layout";
}
- Change the layout path in /Areas/Identity/Pages/Account/Manage/_Layout.cshtml from
@{
Layout = "/Areas/Identity/Pages/_Layout.cshtml";
}
to
@{
Layout = "/Pages/Shared/_Layout.cshtml";
}
EDIT by @Rick-Anderson
The layout generated by the templates is correct. See this GithHub comment for details.
With ASP.NET Core 3.1, the only problem with navigation after scaffolding is https://github.com/dotnet/Scaffolding/issues/1350, the links on the 2FA page are not styled correctly.
To repo:
dotnet new webapp -au Individual -uld -o RPauth
cd RPauth
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet aspnet-codegenerator identity -dc RPauth.Data.ApplicationDbContext
Register > sign in > select login > select 2FA
To fix, replace class="btn btn-default" with class="btn btn-primary" like the rest of the templates.
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
@rjax 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.
It's not clear to me what you're suggesting. I'm using VS 2017. The dialog that is opened when adding the scaffolding allows me to 'Select an existing layout page, or specify a new one:' or '(Leave empty if it is set in a Razor _viewstart file). Up till now I have left this empty. In response to you're question I have tried ~/Pages/Shared/_Layout.cshtml and /Areas/Identity/Pages/Account/Manage/_Layout.cshtml. Neither of these made any difference. Do you have another suggestion?
OK, after much mucking around I have found the following:
- Specifying the layout file in the scaffolding dialog doesn't seem to do anything. I have only made a cursory check of this.
- To get the navigation working you need to do two things after running the scaffolding:
- Add a _viewstart.cshtml to the Manage folder to set the layout
@{
Layout = "_Layout";
}
- Change the layout path in /Areas/Identity/Pages/Account/Manage/_Layout.cshtml from
@{
Layout = "/Areas/Identity/Pages/_Layout.cshtml";
}
to
@{
Layout = "/Pages/Shared/_Layout.cshtml";
}
@rjax
'(Leave empty if it is set in a Razor _viewstart file). Up till now I have left this empty.
The instructions say to use ~/Pages/Shared/_Layout.cshtml
This problem was reported in #7827 but after upgrading VS and .NET Core SDK, he can't reproduce the problem. I can't reproduce the problem when following the instructions.
Add a _viewstart.cshtml to the Manage folder to set the layout
The scaffolder adds that
I'm using VS Enterprise 2017 v15.8.2, .NET Framework 4.7.02558 Microsoft.AspNetCore.App 2.1.1, Microsoft.NETCore.App 2.1.0, Microsoft.VisualStudio.Web.CodeGeneration.Design 2.1.3. I just created a new project and added the scaffolding again while setting the layout to ~/Pages/Shared/_Layout.cshtml as instructed:
- _viewstart.cshtml is included in the the Identity/Pages folder with
Layout = "/Pages/Shared/_Layout.cshtml";This is the correct result and is the same as when the layout is not set in the scaffolding dialog. - Identity\Pages\Account\Manage_Layout.cshtml is created with
Layout = "/Areas/Identity/Pages/_Layout.cshtml";This incorrect. the layout needs to beLayout = "/Pages/Shared/_Layout.cshtml"; - No _viewstart.cshtml has been added to the Identity\Pages\Account\Manage folder. This results in all of the pages in the Manage folder using the layout /Pages/Shared/_Layout.cshtml as set in Identity/Pages/_viewstart.cshtml instead of Identity/Pages/Account/Manage/_Layout.cshtml.
I can't speak for Yanal-Yves (https://github.com/aspnet/Docs/issues/7827) but I have created at least 5 projects in the last couple of days using the environement described above and I am able to reproduce the issue consistently. That said, the problem seems to be with the scaffolder and not the documentation although it might be useful to show the resulting file structure with a short discussion about what you get. Thanks for your time and effort in trying to help.
Why are you using .NET Framework and not .NET Core? Are you using RP or MVC?
Can you repo the isssue when you're targeting .NET Core? @rjax we need to figure out how you can reproduce the issue and we can't. What's different?
@rjax this is in my Areas\Identity\Pages\Account\Manage\_Layout.cshtml project that works correctly:
@{
Layout = "/Areas/Identity/Pages/_Layout.cshtml";
}
You can see my layout banner works

I think that we have a misunderstanding here. When I spoke of navigation I was referring to the navigation that appears with in the form, not the black navigation bar at the top of the page. If I knew how to upload an image I would show you exactly what I mean. In any case your image shows the problem as well. I you add identity to your project and don't override the GUI all of the account management pages include navigation on the left hand side of the form; Profile, Password, Two Factor Authentication and Personal Data. These are missing in you screen shot. If you set the layouts as detailed above these items will be be added to the form.

@rjax thanks for the clarification. We'll get this fixed.
On Sep 19, 2018 6:48 PM, ameteiver [email protected] wrote:
Any suggested workaround available to get the navigation back in place?
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/aspnet/Docs/issues/8440#issuecomment-422854424, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ApO0wCKjbHl_TcS67ZtsarwaRSItbqQzks5ucmc6gaJpZM4WdrI0.
The workaround is described in the thread.
If you have your views in the "Views" folder then when applying the fix provided by @rjax be sure to change the path from Layout = "/Pages/Shared/_Layout.cshtml"; to Layout = "/Views/Shared/_Layout.cshtml";. With this in place everything worked perfectly for my team.
If someone's still confused, I'd like to add that in @rjax's reply the /Areas/Identity/Pages/Account/Manage/_ViewStart.cshtml
@{
Layout = "_Layout";
}
didn't work in my case (Rider 2018.2.3) because it was pointing to the _Layout.cshtml in /Pages/Shared/

but adding .cshtml seems to fix the path, and the side navigation bar is finally visible.
@{
Layout = "_Layout.cshtml";
}

Using ASP.NET Core SDK 2.2.101 I had the same problem. The problem was the _ViewStart.cshtml file was not added by the scaffold process. Add a default _ViewStart.cshtml page fixed the issue.
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!!!.
Just to say I had this issue , doing 1 and 2 above (I didn't had a _ViewStart.cshtml) fixed it. Thanks
+1 for this strange issue. Had me chasing my tail for a while. Trial and error of the methods mentioned worked eventually. Missing _ViewStart file inside /Areas/Identity/Pages/Account/Manage was the main one I think.
Thanks @rjax for the solution!