Migrated RenderNoContentController + related (#9309)
* Migrated RenderNoContentController + related Signed-off-by: Bjarke Berg <mail@bergmania.dk> * Fix after MSDI Signed-off-by: Bjarke Berg <mail@bergmania.dk> * Update src/Umbraco.Web.UI/Umbraco.Web.UI.csproj Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com> * Removing connection string * Fixed tests after moving endpoint registration Signed-off-by: Bjarke Berg <mail@bergmania.dk> Co-authored-by: Elitsa Marinovska <elm@umbraco.dk> Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
namespace Umbraco.Web.Models
|
||||
{
|
||||
public class NoNodesViewModel
|
||||
{
|
||||
public string UmbracoPath { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web.Models;
|
||||
|
||||
namespace Umbraco.Web.Mvc
|
||||
{
|
||||
public class RenderNoContentController : Controller
|
||||
{
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
|
||||
public RenderNoContentController(IUmbracoContextAccessor umbracoContextAccessor, IIOHelper ioHelper, GlobalSettings globalSettings)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
|
||||
_globalSettings = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings));
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
var store = _umbracoContextAccessor.UmbracoContext.Content;
|
||||
if (store.HasContent())
|
||||
{
|
||||
// If there is actually content, go to the root.
|
||||
return Redirect("~/");
|
||||
}
|
||||
|
||||
var model = new NoNodesViewModel
|
||||
{
|
||||
UmbracoPath = _ioHelper.ResolveUrl(_globalSettings.UmbracoPath),
|
||||
};
|
||||
|
||||
return View(_globalSettings.NoNodesViewPath, model);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ namespace Umbraco.Web.Runtime
|
||||
// set the render & plugin view engines
|
||||
ViewEngines.Engines.Add(new RenderViewEngine(_hostingEnvironment));
|
||||
ViewEngines.Engines.Add(new PluginViewEngine());
|
||||
|
||||
|
||||
////add the profiling action filter
|
||||
//GlobalFilters.Filters.Add(new ProfilingActionFilter());
|
||||
|
||||
@@ -122,9 +122,6 @@ namespace Umbraco.Web.Runtime
|
||||
);
|
||||
defaultRoute.RouteHandler = new RenderRouteHandler(umbracoContextAccessor, ControllerBuilder.Current.GetControllerFactory(), shortStringHelper);
|
||||
|
||||
// register no content route
|
||||
RouteNoContentController(umbracoPath);
|
||||
|
||||
// register install routes
|
||||
// RouteTable.Routes.RegisterArea<UmbracoInstallArea>();
|
||||
|
||||
@@ -135,14 +132,6 @@ namespace Umbraco.Web.Runtime
|
||||
RoutePluginControllers(globalSettings, surfaceControllerTypes, apiControllerTypes, hostingEnvironment);
|
||||
}
|
||||
|
||||
private static void RouteNoContentController(string umbracoPath)
|
||||
{
|
||||
RouteTable.Routes.MapRoute(
|
||||
Constants.Web.NoContentRouteName,
|
||||
umbracoPath + "/UmbNoContent",
|
||||
new { controller = "RenderNoContent", action = "Index" });
|
||||
}
|
||||
|
||||
private static void RoutePluginControllers(
|
||||
GlobalSettings globalSettings,
|
||||
SurfaceControllerTypeCollection surfaceControllerTypes,
|
||||
|
||||
@@ -151,8 +151,6 @@
|
||||
<Compile Include="WebApi\Filters\EnableOverrideAuthorizationAttribute.cs" />
|
||||
<Compile Include="WebApi\Filters\OverridableAuthorizationAttribute.cs" />
|
||||
<Compile Include="WebAssets\CDF\ClientDependencyRuntimeMinifier.cs" />
|
||||
<Compile Include="Models\NoNodesViewModel.cs" />
|
||||
<Compile Include="Mvc\RenderNoContentController.cs" />
|
||||
<Compile Include="HttpContextAccessorExtensions.cs" />
|
||||
<Compile Include="Logging\OwinLogger.cs" />
|
||||
<Compile Include="Logging\OwinLoggerFactory.cs" />
|
||||
|
||||
Reference in New Issue
Block a user