I cant Sign in using Asp net core identity : PasswordSignInAsync

samir karim 25 Reputation points
2024-01-01T13:57:17.8266667+00:00

Hello,

im using a .net core Web app with angular , and i want to create an Authentiation Form ,

so i have this Code

User's image

My problem is : IsAuthenticated is always False , si i cant Sign in

but i tried Postman , and it worked :

User's image

Developer technologies ASP.NET ASP.NET Core
0 comments No comments
{count} votes

Accepted answer
  1. AgaveJoe 30,126 Reputation points
    2024-01-01T15:01:37.4566667+00:00

    The PasswordSignInAsync creates an authentication cookie which is returned to the browser. On the next and subsequent requests the browser sends the cookie which is used to populate the user's (User) principal. Also, if the apiSigIn is an API, API does not use cookies by default. You did not share the configuration so we have no way of knowing how the application is setup.

    I recommend creating a Razor Pages or MVC application and scaffolding Identity which has sample code you can review. You'll notice that after a successful sign in, the browser is redirected.

    Also see the official documentation which illustrates how to use Identity in an SPA.

    How to use Identity to secure a Web API backend for SPAs


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.