# Conflicts: # src/Umbraco.Abstractions/Constants-AppSettings.cs # src/Umbraco.Abstractions/ContentVariationExtensions.cs # src/Umbraco.Abstractions/IMainDom.cs # src/Umbraco.Abstractions/PropertyEditors/MultiUrlPickerConfiguration.cs # src/Umbraco.Abstractions/Runtime/IMainDom.cs # src/Umbraco.Abstractions/Runtime/MainDom.cs # src/Umbraco.Core/IMainDom.cs # src/Umbraco.Core/MainDom.cs # src/Umbraco.Core/Umbraco.Core.csproj # src/Umbraco.Infrastructure/MainDom.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs # src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs # src/Umbraco.Web.UI/Umbraco/config/lang/en.xml # src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs # src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs # src/Umbraco.Web/UmbracoApplication.cs # src/Umbraco.Web/UmbracoComponentRenderer.cs
82 lines
3.2 KiB
C#
82 lines
3.2 KiB
C#
using System.Configuration;
|
|
using System.Threading;
|
|
using System.Web;
|
|
using Umbraco.Core;
|
|
using Umbraco.Core.Logging.Serilog;
|
|
using Umbraco.Core.Runtime;
|
|
using Umbraco.Core.Configuration;
|
|
using Umbraco.Core.Hosting;
|
|
using Umbraco.Core.IO;
|
|
using Umbraco.Core.Logging;
|
|
using Umbraco.Core.Persistence;
|
|
using Umbraco.Web.Runtime;
|
|
|
|
namespace Umbraco.Web
|
|
{
|
|
/// <summary>
|
|
/// Represents the Umbraco global.asax class.
|
|
/// </summary>
|
|
public class UmbracoApplication : UmbracoApplicationBase
|
|
{
|
|
protected override IRuntime GetRuntime(Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
|
|
{
|
|
|
|
var connectionStringConfig = configs.ConnectionStrings()[Constants.System.UmbracoConnectionName];
|
|
|
|
var dbProviderFactoryCreator = new UmbracoDbProviderFactoryCreator(connectionStringConfig?.ProviderName);
|
|
|
|
// Determine if we should use the sql main dom or the default
|
|
var appSettingMainDomLock = ConfigurationManager.AppSettings[Constants.AppSettings.MainDomLock];
|
|
|
|
var mainDomLock = appSettingMainDomLock == "SqlMainDomLock"
|
|
? (IMainDomLock)new SqlMainDomLock(logger, configs, dbProviderFactoryCreator)
|
|
: new MainDomSemaphoreLock(logger, hostingEnvironment);
|
|
|
|
var mainDom = new MainDom(logger, hostingEnvironment, mainDomLock);
|
|
|
|
return new WebRuntime(this, configs, umbracoVersion, ioHelper, logger, profiler, hostingEnvironment, backOfficeInfo, dbProviderFactoryCreator, mainDom);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Restarts the Umbraco application.
|
|
/// </summary>
|
|
public static void Restart()
|
|
{
|
|
// see notes in overload
|
|
|
|
var httpContext = HttpContext.Current;
|
|
if (httpContext != null)
|
|
{
|
|
httpContext.Application.Add("AppPoolRestarting", true);
|
|
httpContext.User = null;
|
|
}
|
|
Thread.CurrentPrincipal = null;
|
|
HttpRuntime.UnloadAppDomain();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Restarts the Umbraco application.
|
|
/// </summary>
|
|
public static void Restart(HttpContextBase httpContext)
|
|
{
|
|
if (httpContext != null)
|
|
{
|
|
// we're going to put an application wide flag to show that the application is about to restart.
|
|
// we're doing this because if there is a script checking if the app pool is fully restarted, then
|
|
// it can check if this flag exists... if it does it means the app pool isn't restarted yet.
|
|
httpContext.Application.Add("AppPoolRestarting", true);
|
|
|
|
// unload app domain - we must null out all identities otherwise we get serialization errors
|
|
// http://www.zpqrtbnk.net/posts/custom-iidentity-serialization-issue
|
|
httpContext.User = null;
|
|
}
|
|
|
|
if (HttpContext.Current != null)
|
|
HttpContext.Current.User = null;
|
|
|
|
Thread.CurrentPrincipal = null;
|
|
HttpRuntime.UnloadAppDomain();
|
|
}
|
|
}
|
|
}
|