diff --git a/src/Umbraco.Core/WebAssets/IRuntimeMinifier.cs b/src/Umbraco.Core/WebAssets/IRuntimeMinifier.cs
index 03f6b179ff..2b68a2f4ec 100644
--- a/src/Umbraco.Core/WebAssets/IRuntimeMinifier.cs
+++ b/src/Umbraco.Core/WebAssets/IRuntimeMinifier.cs
@@ -34,7 +34,7 @@ namespace Umbraco.Core.WebAssets
///
/// An html encoded string
///
- string RenderCssHere(string bundleName);
+ Task RenderCssHereAsync(string bundleName);
///
/// Creates a JS bundle
@@ -56,7 +56,7 @@ namespace Umbraco.Core.WebAssets
///
/// An html encoded string
///
- string RenderJsHere(string bundleName);
+ Task RenderJsHereAsync(string bundleName);
///
/// Returns the asset paths for the bundle name
diff --git a/src/Umbraco.Web.BackOffice/ActionResults/JsonNetResult.cs b/src/Umbraco.Web.BackOffice/ActionResults/JsonNetResult.cs
deleted file mode 100644
index db5c7a8510..0000000000
--- a/src/Umbraco.Web.BackOffice/ActionResults/JsonNetResult.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-using System.IO;
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Mvc;
-using Newtonsoft.Json;
-
-namespace Umbraco.Web.BackOffice.ActionResults
-{
- ///
- /// Custom json result using newtonsoft json.net
- ///
- public class JsonNetResult : IActionResult
- {
- public Encoding ContentEncoding { get; set; }
- public string ContentType { get; set; }
- public object Data { get; set; }
-
- public JsonSerializerSettings SerializerSettings { get; set; }
- public Formatting Formatting { get; set; }
-
- public JsonNetResult()
- {
- SerializerSettings = new JsonSerializerSettings();
- }
-
- public Task ExecuteResultAsync(ActionContext context)
- {
- if (context is null)
- throw new ArgumentNullException(nameof(context));
-
- var response = context.HttpContext.Response;
-
- response.ContentType = string.IsNullOrEmpty(ContentType) == false
- ? ContentType
- : System.Net.Mime.MediaTypeNames.Application.Json;
-
- if (!(ContentEncoding is null))
- response.Headers.Add(Microsoft.Net.Http.Headers.HeaderNames.ContentEncoding, ContentEncoding.ToString());
-
- if (!(Data is null))
- {
- using var bodyWriter = new StreamWriter(response.Body);
- using var writer = new JsonTextWriter(bodyWriter) { Formatting = Formatting };
- var serializer = JsonSerializer.Create(SerializerSettings);
- serializer.Serialize(writer, Data);
- }
-
- return Task.CompletedTask;
- }
- }
-}
diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs
index aecad8c4e4..e7e817f649 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs
@@ -1,11 +1,11 @@
using System;
+using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
-using Newtonsoft.Json;
using Umbraco.Core;
using Umbraco.Core.BackOffice;
using Umbraco.Core.Cache;
@@ -15,8 +15,6 @@ using Umbraco.Core.Hosting;
using Umbraco.Core.Services;
using Umbraco.Core.WebAssets;
using Umbraco.Extensions;
-using Umbraco.Net;
-using Umbraco.Web.BackOffice.ActionResults;
using Umbraco.Web.BackOffice.Filters;
using Umbraco.Web.Common.ActionResults;
using Umbraco.Web.Models;
@@ -93,7 +91,7 @@ namespace Umbraco.Web.BackOffice.Controllers
///
///
[HttpGet]
- public JsonNetResult LocalizedText(string culture = null)
+ public Dictionary> LocalizedText(string culture = null)
{
var securityHelper = _umbracoContextAccessor.GetRequiredUmbracoContext().Security;
var isAuthenticated = securityHelper.IsAuthenticated();
@@ -125,14 +123,14 @@ namespace Umbraco.Web.BackOffice.Controllers
.ToDictionary(pv => pv.Key, pv =>
pv.ToDictionary(pve => pve.valueAlias, pve => pve.value));
- return new JsonNetResult { Data = nestedDictionary, Formatting = Formatting.None };
+ return nestedDictionary;
}
[UmbracoAuthorize(Order = 0)]
[HttpGet]
- public JsonNetResult GetGridConfig()
+ public IEnumerable GetGridConfig()
{
- return new JsonNetResult { Data = _gridConfig.EditorsConfig.Editors, Formatting = Formatting.None };
+ return _gridConfig.EditorsConfig.Editors;
}
///
@@ -156,7 +154,7 @@ namespace Umbraco.Web.BackOffice.Controllers
}
[HttpGet]
- public async Task ValidatePasswordResetCode([Bind(Prefix = "u")]int userId, [Bind(Prefix = "r")]string resetCode)
+ public async Task ValidatePasswordResetCode([Bind(Prefix = "u")]int userId, [Bind(Prefix = "r")]string resetCode)
{
var user = await _userManager.FindByIdAsync(userId.ToString());
if (user != null)
@@ -180,9 +178,9 @@ namespace Umbraco.Web.BackOffice.Controllers
/// otherwise process the external login info.
///
///
- private async Task RenderDefaultOrProcessExternalLoginAsync(
- Func defaultResponse,
- Func externalSignInResponse)
+ private async Task RenderDefaultOrProcessExternalLoginAsync(
+ Func defaultResponse,
+ Func externalSignInResponse)
{
if (defaultResponse is null) throw new ArgumentNullException(nameof(defaultResponse));
if (externalSignInResponse is null) throw new ArgumentNullException(nameof(externalSignInResponse));
@@ -213,7 +211,7 @@ namespace Umbraco.Web.BackOffice.Controllers
// Used for XSRF protection when adding external logins
private const string XsrfKey = "XsrfId";
- private ActionResult RedirectToLocal(string returnUrl)
+ private IActionResult RedirectToLocal(string returnUrl)
{
if (Url.IsLocalUrl(returnUrl))
{
diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs
index 051193c290..e97ee0d1e5 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs
@@ -48,6 +48,7 @@ namespace Umbraco.Web.BackOffice.Controllers
IGlobalSettings globalSettings,
IUmbracoVersion umbracoVersion,
IContentSettings contentSettings,
+ IHttpContextAccessor httpContextAccessor,
//TreeCollection treeCollection, // TODO: If we need this we need to migrate trees
IHostingEnvironment hostingEnvironment,
IRuntimeSettings settings,
@@ -62,6 +63,7 @@ namespace Umbraco.Web.BackOffice.Controllers
_globalSettings = globalSettings;
_umbracoVersion = umbracoVersion;
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
+ _httpContextAccessor = httpContextAccessor;
//_treeCollection = treeCollection ?? throw new ArgumentNullException(nameof(treeCollection));
_hostingEnvironment = hostingEnvironment;
_settings = settings;
diff --git a/src/Umbraco.Web/HtmlHelperBackOfficeExtensions.cs b/src/Umbraco.Web.BackOffice/Extensions/HtmlHelperBackOfficeExtensions.cs
similarity index 66%
rename from src/Umbraco.Web/HtmlHelperBackOfficeExtensions.cs
rename to src/Umbraco.Web.BackOffice/Extensions/HtmlHelperBackOfficeExtensions.cs
index bf1ad35bec..894ab5f5f6 100644
--- a/src/Umbraco.Web/HtmlHelperBackOfficeExtensions.cs
+++ b/src/Umbraco.Web.BackOffice/Extensions/HtmlHelperBackOfficeExtensions.cs
@@ -1,36 +1,32 @@
-using System.Collections.Generic;
+using Microsoft.AspNetCore.Authentication;
+using Microsoft.AspNetCore.Html;
+using Microsoft.AspNetCore.Mvc.Rendering;
+using Microsoft.AspNetCore.Routing;
+using Newtonsoft.Json;
+using System.Collections.Generic;
using System.Linq;
using System.Text;
-using System.Web;
-using System.Web.Mvc;
-using Microsoft.Owin.Security;
-using Newtonsoft.Json;
+using System.Threading.Tasks;
+using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Hosting;
-using Umbraco.Core.IO;
-using Umbraco.Core.Runtime;
using Umbraco.Core.WebAssets;
-using Umbraco.Web.Composing;
-using Umbraco.Web.Editors;
+using Umbraco.Web.BackOffice.Controllers;
using Umbraco.Web.Features;
using Umbraco.Web.Models;
-using Umbraco.Web.Security;
-using Umbraco.Web.Trees;
+using Umbraco.Web.WebApi;
using Umbraco.Web.WebAssets;
-namespace Umbraco.Web
+namespace Umbraco.Extensions
{
- ///
- /// HtmlHelper extensions for the back office
- ///
public static class HtmlHelperBackOfficeExtensions
{
///
/// Outputs a script tag containing the bare minimum (non secure) server vars for use with the angular app
///
///
- ///
+ ///
///
///
///
@@ -46,10 +42,9 @@ namespace Umbraco.Web
/// These are the bare minimal server variables that are required for the application to start without being authenticated,
/// we will load the rest of the server vars after the user is authenticated.
///
- public static IHtmlString BareMinimumServerVariablesScript(this HtmlHelper html, UrlHelper uri, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IContentSettings contentSettings, TreeCollection treeCollection, IHostingEnvironment hostingEnvironment, IRuntimeSettings settings, ISecuritySettings securitySettings, IRuntimeMinifier runtimeMinifier)
+ public static async Task BareMinimumServerVariablesScriptAsync(this IHtmlHelper html, BackOfficeServerVariables backOfficeServerVariables)
{
- var serverVars = new BackOfficeServerVariables(uri, Current.RuntimeState, features, globalSettings, umbracoVersion, contentSettings, treeCollection, hostingEnvironment, settings, securitySettings, runtimeMinifier);
- var minVars = serverVars.BareMinimumServerVariables();
+ var minVars = await backOfficeServerVariables.BareMinimumServerVariablesAsync();
var str = @"
+
+
+
+ @if (isDebug)
+ {
+ @Html.Raw(profilerHtml.Render())
+ }
+