1

I am working with asp.net core mvc application in which, when I have created project at that time I have choosen no authentication as authentication type. but now I need to use individual authentication for standard functionalities like register, login, forgot password, email verification and all.

problem is I have completed half of development and can't start now from beginning. so need to change authentication type in my existing project.

is there any way to update authentication in existing .net core application.

Kishan Javiya
  • 13
  • 1
  • 4
  • 2
    Possible duplicate of [How add ASP.NET Core identity to existing Core mvc project?](https://stackoverflow.com/questions/50179696/how-add-asp-net-core-identity-to-existing-core-mvc-project) – Simply Ged May 15 '19 at 05:55

1 Answers1

2

You could refer to Scaffold identity into an MVC project without existing authorization to add Identity.

Remember to add migrations and call app.UseAuthentication() from your Configure. method.

If you have your dbContext already, modify it to inherit IdentityDbContext<IdentityUser> and choose it when you do scaffolding instead of creating a new Data context class..

public class ApplicationDbContext : IdentityDbContext<IdentityUser>
Ryan
  • 19,118
  • 10
  • 37
  • 53
  • thanks for your help, I have tried solution which's provide by you. but it generates all the views into area folder and if I moved that files to any folder in view that it shows an error. – Kishan Javiya May 17 '19 at 05:55
  • Have you also moved the service configuration from `IdentityHostingStartup.cs` to your project startup?If you need to change the login path, you need to [configure Identity](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity-configuration?view=aspnetcore-2.2#cookie-settings) – Ryan May 17 '19 at 06:14