ASP.NET Core - Scaffold Identity like MVC

↘锁芯ラ 提交于 2020-08-24 06:01:19

问题


I have created a Web Application MVC project with Individuals User Accounts authentication.

Afterwards I created a custom UserIdentity. I am trying to change the default "Register" view of Identity adding my new fields, however I only managed to scaffold new pages as Razor Pages.

My question is: Is it possible to scaffold these new views in some structure like MVC? I would not like to mix MVC with Razor Pages at all.

If this is not possible, is there any way to creating a controller that overrides the default behavior (Identity/Account/Register for example)?


回答1:


For anyone that wants to "scaffold" identity on MVC, I recommend the following approach:

Go to the official identity ASP.net Github Repository (https://github.com/aspnet/Identity) and download it. Open the solution and search for the IdentitySample.Mvc project. Copy the necessary files to your project.

Important Note: Don't forget to change the namespace on the added files since they belong to a different project.




回答2:


No, it is not possible. The Identity team decided to switch to Razor Pages for the default UI, and now that is all there is. If you like, you can manually create controllers and views, referencing code from the scaffolded Razor Pages to create the same thing in MVC, but that is on you. There is no automatic way to do so.



来源:https://stackoverflow.com/questions/53367899/asp-net-core-scaffold-identity-like-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!