Krasi Nikolov
Krasi Nikolov

Reputation: 129

How to implement simple authentication in ASP.NET MVC 5

I have existing project with a SQL Server database, EF with database first, unit of work and service layer. I need to add ASP.NET MVC project and use existing service to authenticate user.

I found different complicated decisions. I need to use my service in identity or implement authentication without identity.

Upvotes: 3

Views: 4316

Answers (2)

Waleed Chayeb
Waleed Chayeb

Reputation: 31

Please try this package on Nuget (AuthPackage) its enables you to add authentication to your asp.net mvc easily.

  1. install package using Package Manager Console:

     Install-Package AuthPackage
    
  2. add Connection String to your Web.config in (appSettings):

     <add key="connectionString" value="connectionStringHere" />
    
  3. you're ready to register users, login, logout

example:

 public async Task<ActionResult> SignIn()
    {
        var context = System.Web.HttpContext.Current;
        AuthUser authUser = new AuthUser(context);
        await authUser.SignIn("[email protected]", "123456");
        return RedirectToAction("Index", "Home");
    }

You can read the Documentation here

Upvotes: 2

Andrii Tsok
Andrii Tsok

Reputation: 1446

ASP.NET Identity contains full stack of features for implementation authentication.

Details and instructions there: http://www.asp.net/identity/overview/getting-started/introduction-to-aspnet-identity

In my opinion you should to use Identity instead of own implementation because ASP.NET Identity fully tested, stable and has reach implementation also very flexible in development.. Also there are a huge community that can help you in your questions about ASP.NET Identity.

Upvotes: 3

Related Questions