![]() Why is it failing to login if you don't add the middleware that handles the login?!? Otherwise, the MVC middleware runs before the Authentication middleware and will not be working with a populated ClaimsPrincipal. Given that the authentication middleware reads the cookie and subsequently populates the ClaimsPrincipal, it should be clear that the UseAuthentication call must also be before the UseMvc call in order for this to occur in the correct order. the cookie is not being read) and so sees an unauthenticated request and redirects again for login. the cookie is being set), the pipeline middleware (e.g. In your case, although the user has signed in (i.e. ![]() will not be used for authenticating the user and therefore the user will not be authenticated. Without the authentication middleware, the. This is a simplified explanation of what happens, but it highlights the important job that the authentication middleware performs. Populates the User property of HttpContext with a ClaimsPrincipal that represents said user.cookie from the request, which represents the identity of the user making the request. Using the Cookies authentication scheme, the use of UseAuthentication loosely performs the following: ![]() In order to get the ASP.NET Core pipeline to recognise that a user is signed in, a call to UseAuthentication is required in the Configure method of your Startup class, like so: app.UseAuthentication() Īpp.UseMvc() // Order here is important (explained below).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |