AB#5820 - Initialize the webprofiler in asp.net core
This commit is contained in:
@@ -22,6 +22,6 @@ namespace Umbraco.Configuration.Models
|
||||
/// Gets a value indicating whether umbraco is running in [debug mode].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [debug mode]; otherwise, <c>false</c>.</value>
|
||||
public bool DebugMode => _configuration.GetValue(Prefix+":Debug", false);
|
||||
public bool DebugMode => _configuration.GetValue(Prefix+"Debug", false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace Umbraco.Core.Composing
|
||||
"Umbraco.PublishedCache.NuCache",
|
||||
"Umbraco.ModelsBuilder.Embedded",
|
||||
"Umbraco.Examine.Lucene",
|
||||
"Umbraco.Web.Common",
|
||||
"Umbraco.Web.BackOffice",
|
||||
"Umbraco.Web.Website",
|
||||
};
|
||||
|
||||
public DefaultUmbracoAssemblyProvider(Assembly entryPointAssembly)
|
||||
|
||||
@@ -18,6 +18,7 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Logging.Serilog;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Runtime;
|
||||
using Umbraco.Web.Common.Runtime.Profiler;
|
||||
|
||||
namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
{
|
||||
@@ -118,7 +119,7 @@ namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
private static void CreateCompositionRoot(IServiceCollection services)
|
||||
{
|
||||
// TODO: This isn't the best to have to resolve the services now but to avoid this will
|
||||
// require quite a lot of re-work.
|
||||
// require quite a lot of re-work.
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
var httpContextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
|
||||
@@ -142,11 +143,26 @@ namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
new AspNetCoreMarchal());
|
||||
|
||||
var backOfficeInfo = new AspNetCoreBackOfficeInfo(globalSettings);
|
||||
var profiler = new LogProfiler(logger);
|
||||
var profiler = GetWebProfiler(hostingEnvironment, httpContextAccessor);
|
||||
|
||||
Current.Initialize(logger, configs, ioHelper, hostingEnvironment, backOfficeInfo, profiler);
|
||||
}
|
||||
|
||||
private static IProfiler GetWebProfiler(Umbraco.Core.Hosting.IHostingEnvironment hostingEnvironment, IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
// create and start asap to profile boot
|
||||
if (!hostingEnvironment.IsDebugMode)
|
||||
{
|
||||
// should let it be null, that's how MiniProfiler is meant to work,
|
||||
// but our own IProfiler expects an instance so let's get one
|
||||
return new VoidProfiler();
|
||||
}
|
||||
|
||||
var webProfiler = new WebProfiler(httpContextAccessor);
|
||||
webProfiler.Start();
|
||||
|
||||
return webProfiler;
|
||||
}
|
||||
private class AspNetCoreBootPermissionsChecker : IUmbracoBootPermissionChecker
|
||||
{
|
||||
public void ThrowIfNotPermissions()
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<ProjectReference Include="..\Umbraco.Configuration\Umbraco.Configuration.csproj" />
|
||||
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj" />
|
||||
<ProjectReference Include="..\Umbraco.Infrastructure\Umbraco.Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\Umbraco.Web.Common\Umbraco.Web.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Umbraco.Net;
|
||||
|
||||
namespace Umbraco.Web.AspNet
|
||||
namespace Umbraco.Web.Common.AspNetCore
|
||||
{
|
||||
public class AspNetCoreUmbracoApplicationLifetime : IUmbracoApplicationLifetime
|
||||
{
|
||||
@@ -1,20 +0,0 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Web.Common.Middleware;
|
||||
|
||||
namespace Umbraco.Web.Common.Extensions
|
||||
{
|
||||
public static class UmbracoRequestServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddUmbracoRequest(this IServiceCollection services)
|
||||
{
|
||||
var umbracoRequestLifetime = new UmbracoRequestLifetime();
|
||||
|
||||
services.AddSingleton<IUmbracoRequestLifetimeManager>(umbracoRequestLifetime);
|
||||
services.AddSingleton<IUmbracoRequestLifetime>(umbracoRequestLifetime);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Umbraco.Core.Composing;
|
||||
|
||||
namespace Umbraco.Web.Common.Runtime.Profiler
|
||||
{
|
||||
public sealed class WebInitialComponent : IComponent
|
||||
{
|
||||
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Net;
|
||||
using Umbraco.Web.Common.AspNetCore;
|
||||
using Umbraco.Web.Common.Middleware;
|
||||
|
||||
namespace Umbraco.Web.Common.Runtime.Profiler
|
||||
{
|
||||
public class WebInitialComposer : ComponentComposer<WebInitialComponent>, ICoreComposer
|
||||
{
|
||||
|
||||
public override void Compose(Composition composition)
|
||||
{
|
||||
base.Compose(composition);
|
||||
|
||||
var umbracoRequestLifetime = new UmbracoRequestLifetime();
|
||||
|
||||
composition.RegisterUnique<IUmbracoRequestLifetimeManager>(factory => umbracoRequestLifetime);
|
||||
composition.RegisterUnique<IUmbracoRequestLifetime>(factory => umbracoRequestLifetime);
|
||||
composition.RegisterUnique<IUmbracoApplicationLifetime, AspNetCoreUmbracoApplicationLifetime>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ namespace Umbraco.Web.UI.BackOffice
|
||||
{
|
||||
|
||||
services.AddUmbracoConfiguration();
|
||||
services.AddUmbracoRequest();
|
||||
services.AddUmbracoCore();
|
||||
services.AddUmbracoWebsite();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
"AllowedHosts": "*",
|
||||
"Umbraco": {
|
||||
"CMS": {
|
||||
"Hosting": {
|
||||
"Debug": true
|
||||
},
|
||||
"Imaging": {
|
||||
"Resize": {
|
||||
"MaxWidth": 5000,
|
||||
|
||||
Reference in New Issue
Block a user