No need to register controllers into container, DefaultControllerActivator works fine.
This commit is contained in:
@@ -52,6 +52,9 @@ namespace Umbraco.Extensions
|
||||
|
||||
services.TryAddScoped<IIpResolver, AspNetCoreIpResolver>();
|
||||
|
||||
// TODO: MSDI - This needs some work, e.g. additional registrations / not registering as UserManager<BackOfficeIdentityUser>
|
||||
// if we want container validation back on.
|
||||
|
||||
services.BuildUmbracoBackOfficeIdentity()
|
||||
.AddDefaultTokenProviders()
|
||||
.AddUserStore<BackOfficeUserStore>()
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Web.BackOffice.Controllers;
|
||||
using Umbraco.Web.Common.Controllers;
|
||||
using Umbraco.Web.Common.Install;
|
||||
using Umbraco.Web.BackOffice.Trees;
|
||||
|
||||
// the namespace here is intentional - although defined in Umbraco.Web assembly,
|
||||
@@ -27,26 +24,5 @@ namespace Umbraco.Extensions
|
||||
=> composition.WithCollectionBuilder<TreeCollectionBuilder>();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Registers Umbraco backoffice controllers.
|
||||
/// </summary>
|
||||
public static Composition ComposeUmbracoBackOfficeControllers(this Composition composition)
|
||||
{
|
||||
composition.RegisterControllers(new []
|
||||
{
|
||||
typeof(BackOfficeController),
|
||||
typeof(PreviewController),
|
||||
typeof(AuthenticationController),
|
||||
typeof(InstallController),
|
||||
typeof(InstallApiController),
|
||||
});
|
||||
|
||||
var umbracoAuthorizedApiControllers = composition.TypeLoader.GetTypes<UmbracoApiController>();
|
||||
composition.RegisterControllers(umbracoAuthorizedApiControllers);
|
||||
|
||||
return composition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,6 @@ namespace Umbraco.Web.BackOffice.Runtime
|
||||
|
||||
composition.Services.AddUnique<IIconService, IconService>();
|
||||
composition.Services.AddUnique<UnhandledExceptionLoggerMiddleware>();
|
||||
|
||||
composition.ComposeUmbracoBackOfficeControllers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Web.Common.Controllers;
|
||||
using Umbraco.Web.Mvc;
|
||||
|
||||
namespace Umbraco.Extensions
|
||||
{
|
||||
public static class CompositionExtensions
|
||||
{
|
||||
public static void RegisterControllers(this Composition composition, IEnumerable<Type> controllerTypes)
|
||||
{
|
||||
foreach (var controllerType in controllerTypes)
|
||||
composition.Services.AddScoped(controllerType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,7 @@ namespace Umbraco.Web.Common.Runtime
|
||||
//register the install components
|
||||
//NOTE: i tried to not have these registered if we weren't installing or upgrading but post install when the site restarts
|
||||
//it still needs to use the install controller so we can't do that
|
||||
// TODO: MSDI we can fix that
|
||||
composition.ComposeInstaller();
|
||||
|
||||
var umbracoApiControllerTypes = composition.TypeLoader.GetUmbracoApiControllers().ToList();
|
||||
|
||||
@@ -21,9 +21,8 @@ namespace Umbraco.Web.UI.NetCore
|
||||
x.ClearProviders();
|
||||
})
|
||||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); })
|
||||
// TODO: MSDI - this should probably be on one day, more so when we can reduce the number
|
||||
// of times we build a ServiceProvider from services collection
|
||||
// right now it's just painful.
|
||||
// TODO: MSDI - this should probably be on one day
|
||||
// First we need to resolve the composition conditional registration issues see #8563
|
||||
.UseDefaultServiceProvider(options => options.ValidateOnBuild = false)
|
||||
.UseUmbraco();
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Web.Common.Controllers;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.Website.Controllers;
|
||||
|
||||
namespace Umbraco.Extensions
|
||||
{
|
||||
public static class CompositionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers Umbraco website controllers.
|
||||
/// </summary>
|
||||
public static Composition ComposeWebsiteUmbracoControllers(this Composition composition)
|
||||
{
|
||||
composition.RegisterControllers(new []
|
||||
{
|
||||
// typeof(UmbProfileController), //TODO introduce when migrated
|
||||
// typeof(UmbLoginStatusController),//TODO introduce when migrated
|
||||
// typeof(UmbRegisterController),//TODO introduce when migrated
|
||||
// typeof(UmbLoginController),//TODO introduce when migrated
|
||||
typeof(RenderMvcController),
|
||||
typeof(RenderNoContentController),
|
||||
|
||||
});
|
||||
|
||||
var umbracoWebAssembly = typeof(SurfaceController).Assembly;
|
||||
|
||||
// scan and register every PluginController in everything (PluginController is IDiscoverable and IController)
|
||||
var nonUmbracoWebPluginController = composition.TypeLoader.GetTypes<PluginController>().Where(x => x.Assembly != umbracoWebAssembly);
|
||||
composition.RegisterControllers(nonUmbracoWebPluginController);
|
||||
|
||||
// can and register every IRenderMvcController in everything (IRenderMvcController is IDiscoverable)
|
||||
var renderMvcControllers = composition.TypeLoader.GetTypes<IRenderMvcController>().Where(x => x.Assembly != umbracoWebAssembly);
|
||||
composition.RegisterControllers(renderMvcControllers);
|
||||
|
||||
return composition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Web.Website.ViewEngines;
|
||||
@@ -13,8 +9,6 @@ namespace Umbraco.Extensions
|
||||
{
|
||||
public static void AddUmbracoWebsite(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IControllerActivator, ServiceBasedControllerActivator>();
|
||||
|
||||
// Set the render & plugin view engines (Super complicated, but this allows us to use the IServiceCollection
|
||||
// to inject dependencies into the viewEngines)
|
||||
services.AddTransient<IConfigureOptions<MvcViewOptions>, RenderMvcViewOptionsSetup>();
|
||||
@@ -24,8 +18,6 @@ namespace Umbraco.Extensions
|
||||
|
||||
// Wraps all existing view engines in a ProfilerViewEngine
|
||||
services.AddTransient<IConfigureOptions<MvcViewOptions>, ProfilingViewEngineWrapperMvcViewOptionsSetup>();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,6 @@ namespace Umbraco.Web.Website.Runtime
|
||||
public void Compose(Composition composition)
|
||||
{
|
||||
composition.Services.AddUnique<NoContentRoutes>();
|
||||
|
||||
composition
|
||||
.ComposeWebsiteUmbracoControllers()
|
||||
//.SetDefaultRenderMvcController<RenderMvcController>()// default controller for template views
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user