Authentication - Layout and Context - Location / Multiple

Dean Everhart 1,541 Reputation points
2023-04-15T14:18:49.6233333+00:00

How should I handle Layout and Context in a Tutorial Authentication project?

When Scaffolding Identity in the Authentication Tutorial, what is the best location for both the Layout and Context files?

Tutorial: Introduction to Identity on ASP.NET Core / Scaffolding Identity Environment: Net Core 6, Visual Studio Community 2022 (64 bit), WIndows 11

In more complex projects...

Are there suppose to be either separate second layout and/or context files within the Areas.Identity folder separate from the default Views/Shared/_Layout.cshtml and Data/ApplicationDbContext files (separating concerns)? Layout Page Suggested in Dialogue Box (below) Select an existing layout page, or specify a new one: /Areas/Identity/Pages/Account/Manage/_Layout.cshtml Or Default

Views/Shared/_Layout.cshtml

**Context

Default**

Data/ApplicationDbContext

User's image

Developer technologies ASP.NET ASP.NET Core
Developer technologies ASP.NET Other
0 comments No comments
{count} votes

Accepted answer
  1. AgaveJoe 30,126 Reputation points
    2023-04-15T17:28:03.5866667+00:00

    How should I handle Layout and Context in a Tutorial Authentication project?

    According to your other threads, you've already created Identity DbContext, added the migration, updated the database, and added a user account. Do not click the plus sign. Click the dropdown and select the Identity DbContext you already created. For the layout option, you get to select a layout page. Since you created an MVC project, the Areas\Identity\Pages_viewstart.cshtml file should already point to the ~/Views/Shared/_Layout.cshtml. so there is no need to select another layout unless you want or need to.

    Select an Existing layout page, or specify a new one: ~/Views/Shared/_Layout.cshtml (Leave empty if it is set in a Razor _viewstart file)

    By the way, you are not separating concerns. You are actually doing the opposite by creating duplicated code.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.