UmbracoCMS 401 Error: Troubleshooting Failed Resource Loading
Introduction
Hey guys! We've got a situation where UmbracoCMS is throwing a 401 error when trying to load resources, and it seems to be tied to the .NET 10 preview SDK. This article dives deep into the issue, the steps to reproduce it, and the environments where it's happening. We'll break down the bug, explore the expected behavior, and provide a detailed guide for reproducing and debugging the problem. So, let's get started and figure out what's going on!
The Bug: 401 Error with UmbracoCMS
So, the main issue we're tackling is that UmbracoCMS is failing to load pages, and the browser is reporting a 401 error. This usually means there's an authentication problem, but in this case, it seems to be linked to a specific .NET SDK preview version. When running UmbracoCMS with dotnet-sdk-10.0.100-preview.7.25380.108
, the application throws a "Failed to load resource: the server responded with a status of 401()" error. This issue prevents the login page from loading correctly, making it impossible to access the CMS.
Key Details:
- Application: UmbracoCMS
- Operating System: Windows 11 24H2
- CPU: X64
- .NET Build Number: dotnet-sdk-10.0.100-preview.7.25380.108
- Github Link: Umbraco-CMS
The problem occurs specifically with the dotnet-sdk-10.0.100-preview.7.25380.108
build. Previous versions like dotnet-sdk-9.0.303
and dotnet-sdk-10.0.100-preview.7.25374.104
work just fine. This narrows down the issue to a potential regression in the newer preview build.
Expected Behavior
Ideally, the login page should load without any hiccups. You know, smooth sailing! Users should be able to access the UmbracoCMS login page and proceed to log in without encountering any 401 errors. This is the basic expectation for any web application, and when it fails, it's a major roadblock.
Steps to Reproduce
Alright, let's dive into the nitty-gritty of how to reproduce this bug. Follow these steps, and you'll be able to see the issue firsthand.
App Repro Steps
-
Prerequisites: Make sure you've got
dotnet-sdk-10.0.100-preview.7.25380.108
installed on your machine. -
Copy the Application: Grab the Umbraco-CMS files from the specified location (
\\...\2541067\Umbraco-CMS
) and copy them to your local machine. (Since this is a private path, you'll need to use the appropriate internal network location). -
Update runtimeconfig.json: Modify the
Umbraco.Web.UI.runtimeconfig.json
file to use the problematic .NET runtime version. Here’s the snippet you need to update:"frameworks": [ { "name": "Microsoft.NETCore.App", "version": "10.0.0-preview.7.25380.108" }, { "name": "Microsoft.AspNetCore.App", "version": "10.0.0-preview.7.25380.108" } ],
-
Launch the Application: Run
Umbraco.Web.UI.exe
. -
Open Umbraco: Click the "Open Umbraco" button, and you should see the 401 error in your browser's developer tools.
App Debug Steps
For a more in-depth look, you can debug the application. Here’s how:
-
Prerequisites: Ensure
dotnet-sdk-10.0.100-preview.7.25372.102
(or a similar working version) is installed. -
Get the Source Code: Copy the Umbraco-CMS source code from
\\...\2541067\AppSourceCode\Umbraco-CMS-contrib.zip
, extract it to your local machine, or clone it from Umbraco-CMS GitHub repository. -
Adjust Build Settings:
- In
\Umbraco-CMS-contrib\Umbraco-CMS-contrib\Directory.Build.props
, change<TreatWarningsAsErrors>
tofalse
. - Update the
global.json
file to use the .NET version installed on your machine.
- In
-
Initialize Git: Navigate to the
\Umbraco-CMS-contrib\Umbraco-CMS-contrib
folder and run these Git commands:git init git add . git commit -m "initial"
-
Open in Visual Studio: Open
umbraco.sln
with Visual Studio. -
Build the Project: Build the
\Umbraco-CMS-contrib\Umbraco-CMS-contrib\src\Umbraco.Web.UI\Umbraco.Web.UI.csproj
project. -
Update runtimeconfig.json (Again): Modify
\Umbraco-CMS-contrib\Umbraco-CMS-contrib\src\Umbraco.Web.UI\bin\Debug\net9.0\Umbraco.Web.UI.runtimeconfig.json
to use the problematic runtime version:"frameworks": [ { "name": "Microsoft.NETCore.App", "version": "10.0.0-preview.7.25380.108" }, { "name": "Microsoft.AspNetCore.App", "version": "10.0.0-preview.7.25380.108" } ],
-
Set Launch Profile: Switch to launching the application with
Umbraco.Web.UI
from Visual Studio. -
Run the Project: Press F5 to run the
Umbraco.Web.UI
project. -
First-Time Setup (If Applicable): If this is your first time running the application, follow these steps:
- Fill in your Name, Email, and Password.
- Click "Next" twice.
- Click "Install."
-
Open Umbraco (Again): If it's not the first time, just click the "Open Umbraco" button.
Following these steps should reproduce the 401 error, allowing you to debug and investigate further.
Exceptions and Errors
When the bug hits, you'll see the dreaded