Merge branch 'v10/dev' into v10/feature/nullable-reference-types-in-Umbraco.Web.Backoffice
# Conflicts: # src/Umbraco.Core/Cache/MacroCacheRefresher.cs # src/Umbraco.Core/Services/MacroService.cs # src/Umbraco.Core/StaticApplicationLogging.cs # src/Umbraco.Infrastructure/Migrations/Install/DatabaseDataCreator.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MacroRepository.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TrackedReferencesRepository.cs # src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs # src/Umbraco.Infrastructure/Security/UmbracoPasswordHasher.cs # src/Umbraco.Web.BackOffice/Controllers/ImagesController.cs
This commit is contained in:
@@ -2,10 +2,12 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
using Umbraco.Cms.Core.Routing;
|
||||
using Umbraco.Cms.Core.Web;
|
||||
@@ -54,12 +56,14 @@ namespace Umbraco.Cms.Web.Common.Filters
|
||||
{
|
||||
if (content != null)
|
||||
{
|
||||
IUmbracoContextAccessor umbracoContextAccessor = context.HttpContext.RequestServices.GetRequiredService<IUmbracoContextAccessor>();
|
||||
UriUtility uriUtility = context.HttpContext.RequestServices.GetRequiredService<UriUtility>();
|
||||
|
||||
Uri originalRequestUrl = new Uri(context.HttpContext.Request.GetEncodedUrl());
|
||||
Uri cleanedUrl = uriUtility.UriToUmbraco(originalRequestUrl);
|
||||
|
||||
IPublishedRouter router = context.HttpContext.RequestServices.GetRequiredService<IPublishedRouter>();
|
||||
|
||||
var umbracoContext = umbracoContextAccessor.GetRequiredUmbracoContext();
|
||||
|
||||
IPublishedRequestBuilder requestBuilder = await router.CreateRequestAsync(umbracoContext.CleanedUmbracoUrl);
|
||||
IPublishedRequestBuilder requestBuilder = await router.CreateRequestAsync(cleanedUrl);
|
||||
requestBuilder.SetPublishedContent(content);
|
||||
IPublishedRequest publishedRequest = requestBuilder.Build();
|
||||
|
||||
|
||||
@@ -19,8 +19,11 @@ using Umbraco.Cms.Core.Routing;
|
||||
using Umbraco.Cms.Core.Scoping;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Web;
|
||||
using Umbraco.Cms.Infrastructure.PublishedCache;
|
||||
using Umbraco.Cms.Infrastructure.WebAssets;
|
||||
using Umbraco.Cms.Web.Common.DependencyInjection;
|
||||
using Umbraco.Cms.Web.Common.Profiler;
|
||||
using Umbraco.Cms.Web.Common.Routing;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Web.Common.Middleware
|
||||
@@ -50,6 +53,7 @@ namespace Umbraco.Cms.Web.Common.Middleware
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly IDefaultCultureAccessor _defaultCultureAccessor;
|
||||
private readonly IOptions<UmbracoRequestOptions> _umbracoRequestOptions;
|
||||
private SmidgeOptions _smidgeOptions;
|
||||
private readonly WebProfiler? _profiler;
|
||||
|
||||
@@ -59,6 +63,41 @@ namespace Umbraco.Cms.Web.Common.Middleware
|
||||
private static object s_firstBackOfficeRequestLocker = new object();
|
||||
#pragma warning restore IDE0044 // Add readonly modifier
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UmbracoRequestMiddleware"/> class.
|
||||
/// </summary>
|
||||
// Obsolete, scheduled for removal in V11
|
||||
[Obsolete("Use constructor that takes an IOptions<UmbracoRequestOptions>")]
|
||||
public UmbracoRequestMiddleware(
|
||||
ILogger<UmbracoRequestMiddleware> logger,
|
||||
IUmbracoContextFactory umbracoContextFactory,
|
||||
IRequestCache requestCache,
|
||||
IEventAggregator eventAggregator,
|
||||
IProfiler profiler,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
UmbracoRequestPaths umbracoRequestPaths,
|
||||
BackOfficeWebAssets backOfficeWebAssets,
|
||||
IOptionsMonitor<SmidgeOptions> smidgeOptions,
|
||||
IRuntimeState runtimeState,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IDefaultCultureAccessor defaultCultureAccessor)
|
||||
: this(
|
||||
logger,
|
||||
umbracoContextFactory,
|
||||
requestCache,
|
||||
eventAggregator,
|
||||
profiler,
|
||||
hostingEnvironment,
|
||||
umbracoRequestPaths,
|
||||
backOfficeWebAssets,
|
||||
smidgeOptions,
|
||||
runtimeState,
|
||||
variationContextAccessor,
|
||||
defaultCultureAccessor,
|
||||
StaticServiceProvider.Instance.GetRequiredService<IOptions<UmbracoRequestOptions>>())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UmbracoRequestMiddleware"/> class.
|
||||
/// </summary>
|
||||
@@ -74,7 +113,8 @@ namespace Umbraco.Cms.Web.Common.Middleware
|
||||
IOptionsMonitor<SmidgeOptions> smidgeOptions,
|
||||
IRuntimeState runtimeState,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IDefaultCultureAccessor defaultCultureAccessor)
|
||||
IDefaultCultureAccessor defaultCultureAccessor,
|
||||
IOptions<UmbracoRequestOptions> umbracoRequestOptions)
|
||||
{
|
||||
_logger = logger;
|
||||
_umbracoContextFactory = umbracoContextFactory;
|
||||
@@ -86,6 +126,7 @@ namespace Umbraco.Cms.Web.Common.Middleware
|
||||
_runtimeState = runtimeState;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
_defaultCultureAccessor = defaultCultureAccessor;
|
||||
_umbracoRequestOptions = umbracoRequestOptions;
|
||||
_smidgeOptions = smidgeOptions.CurrentValue;
|
||||
_profiler = profiler as WebProfiler; // Ignore if not a WebProfiler
|
||||
|
||||
@@ -96,7 +137,7 @@ namespace Umbraco.Cms.Web.Common.Middleware
|
||||
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
|
||||
{
|
||||
// do not process if client-side request
|
||||
if (context.Request.IsClientSideRequest())
|
||||
if (context.Request.IsClientSideRequest() && !_umbracoRequestOptions.Value.HandleAsServerSideRequest(context.Request))
|
||||
{
|
||||
// we need this here because for bundle requests, these are 'client side' requests that we need to handle
|
||||
LazyInitializeBackOfficeServices(context.Request.Path);
|
||||
|
||||
14
src/Umbraco.Web.Common/Routing/UmbracoRequestOptions.cs
Normal file
14
src/Umbraco.Web.Common/Routing/UmbracoRequestOptions.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Umbraco.Cms.Web.Common.Routing
|
||||
{
|
||||
public class UmbracoRequestOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the delegate that checks if we're gonna handle a request as a client-side request
|
||||
/// this returns true by default and can be overwritten in Startup.cs
|
||||
/// </summary>
|
||||
public Func<HttpRequest, bool> HandleAsServerSideRequest { get; set; } = x => false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user