how to implement ASP.NET Identity to an empty MVC project

前端 未结 4 1908
花落未央
花落未央 2020-11-30 18:35

I create a new empty MVC project and I want to add identity to it. Now I do not know how to do this and how to create database and tables and classes. I searche

4条回答
  •  臣服心动
    2020-11-30 19:12

    Open up the nuget package manager by going to:

    Tools > Nuget Package Manager > Package Manager Console
    

    in a new project[1]. From there, You can enter next to the PM>

    Install-Package Microsoft.AspNet.Identity.Samples -Pre 
    

    which will install the Identity sample for you. It will ask you if you allow it to alter your webconfig by pressing 'A' you accept all changes.

    From then onwards, you'll have the sample identity project installed!

    Note: It will change the default namespace, so by going to 'find and replace' you can quickly alter the occurrences to your project name (note, you may have to go into your global.aspx page in your my documents folder - open it in notepad and change the namespace there too!)


    [1]: If you do not do this at the beginning of your development, you will find that the following files will be overwritten(so make sure you have a way to merge your originals with the new):

    Overwrite existing file 'Views\Web.config'.
    Overwrite existing file 'Views\Shared\Error.cshtml'.
    Overwrite existing file 'Views\Shared\_Layout.cshtml'.
    Overwrite existing file 'Views\Home\Index.cshtml'.
    Overwrite existing file 'Views\_ViewStart.cshtml'.
    Overwrite existing file 'Global.asax.cs'.
    Overwrite existing file 'Global.asax'.
    Overwrite existing file 'Controllers\HomeController.cs'.
    Overwrite existing file 'Content\Site.css'.
    Overwrite existing file 'App_Start\RouteConfig.cs'.
    Overwrite existing file 'App_Start\FilterConfig.cs'.
    Overwrite existing file 'App_Start\BundleConfig.cs'.
    

提交回复
热议问题