Files
Umbraco-CMS/src/Umbraco.Web/ApplicationContextExtensions.cs
sitereactor ec9880968f Moving interfaces for services to Umbraco.Core.
Adding xml extensions for Content to generate xml for the xml cache.
Adding test for xml generation.
2012-11-06 10:47:14 -01:00

31 lines
1.0 KiB
C#

using System;
using System.IO;
using System.Web;
using Umbraco.Core;
namespace Umbraco.Web
{
public static class ApplicationContextExtensions
{
/// <summary>
/// This will restart the application pool
/// </summary>
/// <param name="appContext"> </param>
/// <param name="http"></param>
public static void RestartApplicationPool(this ApplicationContext appContext, HttpContextBase http)
{
//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.
http.Application.Add("AppPoolRestarting", true);
//NOTE: this real way only works in full trust :(
//HttpRuntime.UnloadAppDomain();
//so we'll do the dodgy hack instead
var configPath = http.Request.PhysicalApplicationPath + "\\web.config";
File.SetLastWriteTimeUtc(configPath, DateTime.UtcNow);
}
}
}