Closed ZioTino closed 1 year ago
Hi @ZioTino
Sorry for the ridiculously late answer 🙈
This is actually by design. No custom render controllers are picked up my magic anymore. You will need to specify the one to use. Like in this example, which can be done from a package.
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Cms.Web.Website.Controllers;
namespace MyPackage
{
public class CustomRenderControllerComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.Services.Configure<UmbracoRenderingDefaultsOptions>(c =>
{
c.DefaultControllerType = typeof(MyRenderController);
});
}
}
public class MyRenderController : RenderController
{
public MyRenderController(ILogger<RenderController> logger, ICompositeViewEngine compositeViewEngine, IUmbracoContextAccessor umbracoContextAccessor) : base(logger, compositeViewEngine, umbracoContextAccessor)
{
}
public override IActionResult Index()
{
ViewData["TheMeaningOfLifeTheUniverseAndEverything"] = 42;
return base.Index();
}
}
}
@bergmania you are referencing to setting a default controller. That always had to be explicitly registered. But @ZioTino is talking about route hijacking for a specific doctype.
But to make it short, this works as expected in V10 and V11.
Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9
9.0.1
Bug summary
In Umbraco v8 it was possible to create a RenderMvcController from a package, making it available when you install that package in Umbraco.
This is not possible in v9. as the RenderController created from the package is completely ignored.
Specifics
No response
Steps to reproduce
dotnet new umbracopackage -n MyCustomUmbracoPackage
dotnet new umbraco -n MyCustomUmbracoProject -p MyCustomUmbracoPackage
MyTestDocType
in the test projectMyTestDocTypeController
, inheriting fromRenderController
MyTestDocTypeController
, it will never fire.Expected result / actual result
The RenderController must be picked up from the package and injected into the pipeline, as it was with the old behavior from v8.