Adding Identity to an existing project

断了今生、忘了曾经 提交于 2019-12-23 09:29:17

问题


I've got an MVC project, and I want to add Identity to it, but I can't seem to find any good articles on how to do so.

Is there an easy way to add Identity to an existing project?

I already have a database with stuff in it


回答1:


Well, in one respect, you simply have to add the Nuget package and start writing code with it, but I think you're probably talking about all the extras: the pre-written code and samples for doing things like password resets, two-factor auth, etc.

For that, no, there's not really an easy way, at least in the sense of click a button and go. What I would recommend is creating a new MVC 5 project with Individual Auth, and then adding the Identity Samples Nuget package to it. Then, open your existing project in another Visual Studio window and copy/paste or use the sample code as a guide for writing your own.




回答2:


Here's a tutorial that I followed for adding ASP.Net Identity to an existing project. It's up to date and from a reputed source at the asp.net/identity site.




回答3:


I will echo what Chris said. there is no "easy way" . here is a video link featuring Scott Allen (a pioneer in web dev (Video link)

You can check his other videos as well




回答4:


I think the easiest way to do that is to do the following steps:

  • Install All Identity Packages from nugets to your existing MVC project.

  • Create New MVC Project and choose Authentication type: Individual Authentication.

  • Copy IdentityModels.cs and all related files including (controllers, views and IdentityConfig) from New project to an existing MVC project.

  • Add migration to create required tables on database.



来源:https://stackoverflow.com/questions/28617002/adding-identity-to-an-existing-project

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