Identity in ASP.Net Core 2.1< - Customize AccountController

41,061

Solution 1

One of the changes in 2.1 was Razor Class Libraries and the default identity lives in one of these in the individual auth templates. If you would like to have the code in your app so you can customise it, you can scaffold it out with Visual Studio, or with the global scaffolder tool. See this guide on how to do both.

Solution 2

ASP.NET Core 2.1 introduced new feature called Razor class libraries that lets you build views and pages as part of reusable library. ASP.NET Core Identity was moved to such RCL. You can override it in your project:

  1. From Solution Explorer, right-click on the project > Add > New Scaffolded Item.
  2. From the left pane of the Add Scaffold dialog, select Identity > ADD.
  3. In the ADD Identity dialog, choose files you wish to override.
    1. Select layout if necessary
    2. Select or create Data context class.
  4. Hit ADD.

For more information visit documentation.

Solution 3

My solution is create project with .net core 2.0, and then update the framework to 2.1 and all the dependence to latest version

Solution 4

Turns out ASP.NET Core Identity is now available as a prebuilt package called Microsoft.AspNetCore.Identity.UI.

You can read more about it here:

https://blogs.msdn.microsoft.com/webdev/2018/03/02/aspnetcore-2-1-identity-ui/

Solution 5

Since ASP.NET Core 2.1 the identity UI is shipped as a library.

But you can override the views and controllers by placing them at the right locations (e.g. View/Account/Login.cshtml).

Share:
41,061
Ogglas
Author by

Ogglas

My biggest interest in life is technology, primarily computers. It started out with a general computer interest and the need to know how and why something works. This interest has continued to grow but instead of dissecting computer hardware and removing viruses from friends computers all day long my focus has changed to IT security and programming. The programming language that I prefer is C#. On my spare time I like to do small (and large) technology projects. This can be everything from creating an RFID-reader or 3D printer using an Arduino to participating in vulnerability bounty programs. Another big interest is also my entrepreneurial side. I like to see something grow and instead of just seeing obstacles I try to see possibilities.

Updated on July 08, 2022

Comments

  • Ogglas
    Ogglas almost 2 years

    I have installed ASP.NET Core 2.1 but even though I have created a new ASP.NET Core Web Application using ASP.NET Core 2.1 with Individual User AccountsStore user accounts in-app I can't find the AccountController or Views.

    I can still register and login without a problem but I can't find the code for it, it were present in 2.0.

    enter image description here

  • user1085907
    user1085907 almost 6 years
    I was able to generate cshtml files not controllers. Guide didn't mention it, any idea how to generate accountController?
  • user1085907
    user1085907 almost 6 years
    Ah my bad.. its like designer in subfile
  • YodasMyDad
    YodasMyDad over 5 years
    You need to right click on the project not the solution to get the 'New Scaffolded Item' .. Thanks for the heads up on this
  • liang
    liang almost 5 years
    why is this thing an improvement? It makes things unnecessarily convoluted.
  • c-sharp-and-swiftui-devni
    c-sharp-and-swiftui-devni almost 4 years
    This still does not bring in the Account Controller field say i have added customized fields how do i tell it I need them in the register method.
  • Robert Tirta
    Robert Tirta over 3 years
    Hey what if I want to overwrite the controller instead of the razor page? I'm using SPA so i'm not sure if i can override the controller
  • c-sharp-and-swiftui-devni
    c-sharp-and-swiftui-devni over 3 years
    an accepted answer was already acepted no need to say now @WibisonoIndrawan