In some cases, a successful login using Identity Framework and .NET 6.0 doesn't create a cookie in the browser

Viewed 12

I have a .Net 6.0 Web API project with an Angular application that implements a simple login form with Identity Framework used. I observe strange behavior when I'm running the same frontend application in two different development environments.

The first case is that after successful login, the browser receives a cookie. An angular application is opened in Visual Studio 2022 and running on port 5001 according to the launchSetting.json file.

 "MyApp": {
  "commandName": "Project",
  "launchBrowser": false,
  "applicationUrl": "https://localhost:5001;http://localhost:5000",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  }
}

Expected result image


The second case is that after successful login, the browser doesn't receive the cookie. An Angular application isopened with Visual Studio Code and running on the default port 4200.

Strange behavior image

Is there any place in the project in visual studio that configures the port on which the cookie is created?

Below my Spa configuration:

app.UseSpa(spa =>
        {
           spa.Options.SourcePath = "ClientApp";

            if (env.IsDevelopment())
            {
                spa.UseAngularCliServer(npmScript: "start");
            }
        });

Can anyone explain to me why a running application might behave differently in two different environments?

0 Answers
Related