-1

When I create a web project using "ASP.NET Core Web Application" / "Web Application" (non-MVC) / "Individual User Accounts"... I get the sample project with Register and Login buttons that show their respective pages when I click on them. HOWEVER... the very weird thing is if I search for "Create a new account" which is on the register page it's not found... and more... there is no AccountController in the Identity area or anywhere... so 1) the pages aren't anywhere in my solution folder and 2) how in the world are these pages showing up?!? I've tried on two different computers now. (using Core 2.1)

As an example this link works:

<a asp-area="Identity" asp-page="/Account/Login">Login</a>

and takes me to:

https://localhost:44300/Identity/Account/Login

and yet my folder structure (both in the solution and on disk) looks like this:

enter image description here

Brian Rice
  • 3,107
  • 1
  • 35
  • 53
  • 1
    https://stackoverflow.com/questions/50802781/where-are-the-login-and-register-pages-in-an-aspnet-core-scafolded-app – Alexan Jul 06 '18 at 14:45
  • Possible duplicate of [Where are the Login and Register pages in an AspNet Core scaffolded app?](https://stackoverflow.com/questions/50802781/where-are-the-login-and-register-pages-in-an-aspnet-core-scaffolded-app) – TylerH May 31 '19 at 20:46

2 Answers2

4

ASP.NET Core 2.1 with Identity automatically includes the "Default UI". It's a Razor Pages class library that's referenced via AddDefaultIdentity in Startup, which under the hood literally calls AddDefaultUI.

If you want the actual files in your project, you need to scaffold them in. Right click your project in the solution explorer and choose Add > New Scaffolded Item... Then, click the Identity listing on the left, and then the Add button. A new window will pop allowing you to select the pages you want included, your context, etc. Configure it how you like and go.

It's also worth noting, that as long as you use AddDefaultIdentity, the default UI is still included, which means you don't actually need all the scaffolded files if you want any of them. They'll essentially function as overrides. Anything specifically included in your project will be used, while anything that's missing will be pulled from the default UI.

This also means that if you want to do something like use standard controller actions and views instead of Razor Pages, the default UI will still be active, and take precedence. You have to use AddIdentity or AddIdentityCore instead of AddDefaultIdentity if you want the default UI off completely.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
0

ASP.NET Core 2.1 introduced Razor UI in class libraries. Identity with it's UI is in nuget package.

The nice thing about this is you can now package UI with your libraries and then expose the UI for overriding.

This post describes how to override the UI. Essentially, you add the pages you want to override to your project to /Areas/Identity/Pages.... the easiest way currently is to run the scaffolder for identity and a visual walkthrough.

Kevin LaBranche
  • 20,908
  • 5
  • 52
  • 76