From the course: Learning SignalR with ASP.NET Core

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Add cookie authentication

Add cookie authentication

From the course: Learning SignalR with ASP.NET Core

Start my 1-month free trial

Add cookie authentication

- [Instructor] Since this is a web-based application, we'll add cookie authentication. If you're building a mobile app, you'd use bearer token authentication instead. I created this ASP.NET core app without authentication initially, so I need to add the authentication middleware myself. If you started with the individual off template, you'd have the authentication and ASP.NET core identity components already installed. I want to add cookie authentication to this project so, in the startup class down in the configure services method, I'll do services.AddAuthentication and pass a few options here. I'll say options.DefaultScheme equals CookieAuthenticationDefaults.AuthenticationScheme. And then I'll say .AddCookie to enable the cookie services and I'll say options here is gonna be options.LoginPath, this is where I want the browser to be redirected to if there's an unauthenticated session trying to access an authenticated page. If I want it to go to /Login. /Login is a page that I've…

Contents