9

I am using Asp.net core and I have scaffolded all the identity pages, it created a folder in my root directory named areas > Identity > Pages, and I have all the razor pages here and some pages in accounts folder and some in manage folder as shown in attached photo.

enter image description here

Problem is I cannot find the layout page for my edit profile page which is present in

Areas > Identity > Pages > Account > Manage > Index.cshtml

enter image description here

I have a _Layout.cshtml file in the manage folder which is referencing a layout like

@{
Layout = "/Areas/Identity/Pages/_Layout.cshtml";
}

But I cannot find the file in my directory which is being referenced, I have the following files in my Pages directory

enter image description here.

I even tried to scaffold _layout.cshtml file again to see if I have not missed that using Add > New Scaffold Item > Identity and I cant even find it here too

enter image description here

The Issue is in my Views > Shared > _Layout.cshtml file I have added my project's logo and its working fine on home page

enter image description here

but when I go to my profile page I see only my Project's name on the header and I cannot change it to my logo

enter image description here

I want my project's logo in my profile page, the page which I cannot find in my solution. Any help will be greatly appreciated.

Hamza Khanzada
  • 1,439
  • 1
  • 22
  • 39

3 Answers3

7

Ensure to specify your layout file when scaffolding Identity, as shown in Scaffold Identity in ASP.NET Core projects.

You could also just adapt the Layout variable to your existing layout file, e.g. (for a default ASP.NET Core MVC project):

Layout = "/Views/Shared/_Layout.cshtml";
user7217806
  • 2,014
  • 2
  • 10
  • 12
  • 1
    Changing `Layout = "/Areas/Identity/Pages/_Layout.cshtml";` to `Layout = "/Views/Shared/_Layout.cshtml";` solved my issue. Thankyou so much for this. This was exactly what I was looking for – Hamza Khanzada Oct 20 '19 at 08:24
  • I wonder why the _Layout.cshtml is hidden. Is it supposed to be changed by developer? – DavidY May 12 '22 at 12:18
  • @DavidY what do you mean by hidden? Yes, it is expected to be customized. – user7217806 May 13 '22 at 22:26
3

After scaffolding all files:

  1. Set Layout = "/Views/Shared/_Layout.cshtml"; in the file \Areas\Identity\Pages\Account\Manage_Layout.cshtml. For Net core 3.0 it is a matter of changing the else block in the top.
  2. Set Layout = "/Areas/Identity/Pages/Account/Manage/_Layout.cshtml"; in every cshtml file that you want to display in the left hand pane of the Manage section; the "fixed" options there.
netfed
  • 602
  • 8
  • 18
0

I have encountered with a similar problem. I have started an ASP.NET Core MVC Web project. And I couldnt find '_Layout.cshtml' file under 'Shared' folder. I also wanted to use 'Awesomefont' script link in HTML header to include few icons.

With .NET CORE 5.0.101 SDK and Microsoft Visual Studio Community 2019 version 16.8.3. It seems like there are a lot of new changes involved.

Here is the solution: Search for '_Layout.cshtml' on 'Solution Explorer' (on right hand side). You will find it under Views/Shared/_Layout.cshtml. Right click the file _Layout.cshtml and choose 'Scope to This'.

Viola! All three missing files will be visible under 'Shared' folder.