Skip to content

[dotnet-sdk-10.0.100-preview.7.25351.101] The SANDWITCH app failed to load data due to a 401 Unauthorized error. #117445

@Junjun-zhao

Description

@Junjun-zhao

Description

When third-party application SANDWITCH running with .NET 10 using dotnet-sdk-10.0.100-preview.7.25351.101, the following errors appear in the command prompt:

info: Sandwitch.Tier.Authentication.Classes.BasicAuthenticationHandler[7]
      Basic was not authenticated. Failure message: Authorization Error. Authentication Error
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2]
      Authorization failed. These requirements were not met:
      DenyAnonymousAuthorizationRequirement: Requires an authenticated user.
info: Sandwitch.Tier.Authentication.Classes.BasicAuthenticationHandler[12]
      AuthenticationScheme: Basic was challenged.
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/2 GET https://localhost:7297/api/provincia/findallprovincia - 401 0 - 44.0004ms

Reproduction Steps

App Repro steps:

Please get the reoro machine from devdiv bug

1.Update the "C:\Users\test01\Desktop\App\SANDWITCH\Service\Sandwitch.Tier.Service.runtimeconfig.json" to run against with .NET 10:

{
  
    "runtimeOptions": {
      "tfm": "net9.0",
      "frameworks": [
        {
          "name": "Microsoft.NETCore.App",
          "version": "10.0.0-preview.7.25351.101"
        },
        {
          "name": "Microsoft.AspNetCore.App",
          "version": "10.0.0-preview.7.25351.101"
        }
      ],
      "configProperties": {
        "System.GC.Server": true,
        "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
        "System.Reflection.NullabilityInfoContext.IsSupported": true,
        "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
      }
    }
  }

2.Launch cmd.
3.Execute “cd C:\Users\test01\Desktop\App\SANDWITCH\Client”.
If “C:\Users\test01\Desktop\App\SANDWITCH\Client\node_modules” already exists, please skip step 4
4.Execute “npm install”.
5.Execute “npm start”.
6.Launch another cmd.
7.Execute “cd C:\Users\test01\Desktop\App\SANDWITCH\Service”.
8.Execute "dotnet dev-certs https --trust".
9.Execute “set ASPNETCORE_ENVIRONMENT=Development”.
10.Execute “dotnet Sandwitch.Tier.Service.dll --urls=https://localhost:7297”.
11. Launch edge and access URL: “https://localhost:4200”.
12.Click “Poblaciones” tab.

Expected behavior

Data loaded normally.

Actual behavior

Fail to load the resource.

When opening the Developer Tools in Edge by pressing F12, the following problem is observed:

Failed to load resource: the server responded with a status of 401 ()

:16175/v1/traces:1  
Failed to load resource: net::ERR_CONNECTION_REFUSED


The following errors appear in the command prompt:
info: Sandwitch.Tier.Authentication.Classes.BasicAuthenticationHandler[7]
      Basic was not authenticated. Failure message: Authorization Error. Authentication Error
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2]
      Authorization failed. These requirements were not met:
      DenyAnonymousAuthorizationRequirement: Requires an authenticated user.
info: Sandwitch.Tier.Authentication.Classes.BasicAuthenticationHandler[12]
      AuthenticationScheme: Basic was challenged.
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/2 GET https://localhost:7297/api/provincia/findallprovincia - 401 0 - 44.0004ms

Image

Regression?

Yes

Verify Scenarios:
1). Windows 10 22H2 AMD64 + dotnet-sdk-9.0.302: Pass
2). Windows 10 22H2 AMD64 + dotnet-sdk-10.0.100-preview.6.25321.102: Pass
3). Windows 10 22H2 AMD64 + dotnet-sdk-10.0.100-preview.7.25351.101: Fail

Known Workarounds

No response

Configuration

Application Name: SANDWITCH
OS: Windows 10 22H2
CPU: X64
.NET Build Number: dotnet-sdk-10.0.100-preview.7.25351.101

Shared App & App Source Location checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2520984

Github Link:
https://github.com/javierpardollama/SANDWITCH

Other information

Findings:
We found that the issue was caused by the application failing to correctly load values from appsettings.Development.json in development mode.
Despite setting the environment variable using set ASPNETCORE_ENVIRONMENT=Development before running the app, it still loaded settings from appsettings.json.
Specifically, the value of ApiLock in appsettings.json is "Pauline", while in appsettings.Development.json it is "Peach".
However, when running the application in development mode with .NET 10 Preview 7 build, ApiLock is "Pauline". In contrast, when running in development mode on.NET 9.0, it correctly used "Peach".

@dotnet-actwx-bot @dotnet/compat

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions