Identity in ASP.Net Core 2.1< - Customize AccountController
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:
- From Solution Explorer, right-click on the project > Add > New Scaffolded Item.
- From the left pane of the Add Scaffold dialog, select Identity > ADD.
- In the ADD Identity dialog, choose files you wish to override.
- Select layout if necessary
- Select or create Data context class.
- 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).
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, 2022Comments
-
Ogglas almost 2 years
I have installed
ASP.NET Core 2.1
but even though I have created a newASP.NET Core Web Application
usingASP.NET Core 2.1
withIndividual User Accounts
→Store 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.
-
user1085907 almost 6 yearsI was able to generate cshtml files not controllers. Guide didn't mention it, any idea how to generate accountController?
-
user1085907 almost 6 yearsAh my bad.. its like designer in subfile
-
YodasMyDad over 5 yearsYou need to right click on the project not the solution to get the 'New Scaffolded Item' .. Thanks for the heads up on this
-
liang almost 5 yearswhy is this thing an improvement? It makes things unnecessarily convoluted.
-
c-sharp-and-swiftui-devni almost 4 yearsThis 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 over 3 yearsHey 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 over 3 yearsan accepted answer was already acepted no need to say now @WibisonoIndrawan