Closed lauraneto closed 9 months ago
The ConfigureUmbracoDefaults
method seems to also not have the intended effect when using the minimal hosting model.
As it will never set the StaticServiceProvider.Instance
Based on a working Umbraco 9 minimal host, I only had to add ConfigureUmbracoDefaults()
to make it work on .NET6 and Umbraco 10.
If you want to check out a working version that is using a startup class, check out this gist. It might give you some hints.
Hi @BeardInASuit
By using UseStartup<Startup>()
in your example you are functionally opting-out of using the new minimal hosting model.
This makes it so you are effectively just using the ASP.NET Core 5 hosting model, and the reason you don't see any issues.
As such, the issue still stands, and the new .NET 6 minimal hosting model should be supported by Umbraco.
Hey guys,
For anyone looking for a workaround, I did managed to use .NET 6 minimal hosting modal by calling the following just after building the application:
// This is what ConfigureUmbracoDefaults does after building the host and it's required, otherwise it crashes within the Umbraco initialization at startup.
StaticServiceProvider.Instance = app.Services;
// Another workaround due to the nature of the Umbraco initialization strategy. More info over there: https://github.com/umbraco/Umbraco-CMS/issues/12445
app.Services.GetRequiredService<IRuntimeState>().DetermineRuntimeLevel();
Hope this helps anyone!
Just posting an update here: This is wrong by design an is not really a "bug". This is will be a big task, and it will require som investigation from HQ. Sadly no updates on when this will get implemented, but we are investigating it 😊
As this is now being released for v13, I will close this! 🙌
Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9
10.0.0-rc2
Bug summary
When using the minimal hosting model, the backoffice is not accessible in
/umbraco
.As a temporary workaround we are forced to manually call
app.Services.GetRequiredService<IRuntimeState>().DetermineRuntimeLevel();
Specifics
Umbraco's architecture relies on the execution order of the
CoreRuntime
hosted service and the web host. It specifically relies on the fact that previously hosted services were started before the web host, which is no longer the case with the new minimal hosting model. As such, when the routes are registered here, the runtime level will still beUnknown
.This is related to https://github.com/dotnet/aspnetcore/issues/39037
Steps to reproduce
Use the following
Program.cs
:/umbraco
and verify that it doesn't work.Expected result / actual result
As Umbraco 10 now officially supports ASP.NET Core 6, it should support the minimal hosting model as well. The route registration code should not rely on the
CoreRuntime
hosted service having ran.