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:
Bjarke Berg
2020-11-03 18:55:55 +01:00
committed by GitHub
parent 3cf45c9e88
commit dae6e2b8ee
20 changed files with 115 additions and 58 deletions

View File

@@ -1,7 +0,0 @@
namespace Umbraco.Web.Models
{
public class NoNodesViewModel
{
public string UmbracoPath { get; set; }
}
}

View File

@@ -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);
}
}
}

View File

@@ -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,

View File

@@ -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" />