O'Reilly logo

Hands-On Design Patterns with C# and .NET Core by Jeffrey Chilberto, Gaurav Aroraa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Authentication in action

In this section, we will see how to implement authentication and make our web pages restricted for unauthenticated requests.

To achieve authentication, we should adopt some sort of mechanism that provides us with a way to authenticate a user. In general cases, if a user is logged in, that means they are already authenticated.

In our web application, we will also follow the same approach and make sure that the user is logged in before accessing the restricted pages, views, and operations:

public class User{    public Guid Id { get; set; }    public string UserName { get; set; }    public string EmailId { get; set; }    public string FirstName { get; set; }    public string LastName { get; set; } public byte[] PasswordHash { get; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required