diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs
index 471e7403ad..abec9e4076 100644
--- a/src/Umbraco.Web/UmbracoContext.cs
+++ b/src/Umbraco.Web/UmbracoContext.cs
@@ -24,7 +24,7 @@ namespace Umbraco.Web
///
/// Class that encapsulates Umbraco information of a specific HTTP request
///
- public class UmbracoContext
+ public class UmbracoContext : DisposableObject
{
private const string HttpContextItemName = "Umbraco.Web.UmbracoContext";
private static readonly object Locker = new object();
@@ -361,7 +361,17 @@ namespace Umbraco.Web
return null;
}
}
-
-
+
+ protected override void DisposeResources()
+ {
+ Security.DisposeIfDisposable();
+ Security = null;
+ _previewContent = null;
+ _umbracoContext = null;
+ //ensure not to dispose this!
+ Application = null;
+ ContentCache = null;
+ MediaCache = null;
+ }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs
index c93b99d180..604e61e55f 100644
--- a/src/Umbraco.Web/UmbracoModule.cs
+++ b/src/Umbraco.Web/UmbracoModule.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.IO;
using System.Linq;
using System.Web;
@@ -166,23 +167,6 @@ namespace Umbraco.Web
return end;
}
- ///
- /// Checks if the xml cache file needs to be updated/persisted
- ///
- ///
- ///
- /// TODO: This needs an overhaul, see the error report created here:
- /// https://docs.google.com/document/d/1neGE3q3grB4lVJfgID1keWY2v9JYqf-pw75sxUUJiyo/edit
- ///
- void PersistXmlCache(HttpContextBase httpContext)
- {
- if (content.Instance.IsXmlQueuedForPersistenceToFile)
- {
- content.Instance.RemoveXmlFilePersistenceQueue();
- content.Instance.PersistXmlToFile();
- }
- }
-
#endregion
#region Route helper methods
@@ -350,7 +334,7 @@ namespace Umbraco.Web
///
///
///
- private void RewriteToUmbracoHandler(HttpContextBase context, PublishedContentRequest pcr)
+ private static void RewriteToUmbracoHandler(HttpContextBase context, PublishedContentRequest pcr)
{
// NOTE: we do not want to use TransferRequest even though many docs say it is better with IIS7, turns out this is
// not what we need. The purpose of TransferRequest is to ensure that .net processes all of the rules for the newly
@@ -402,6 +386,36 @@ namespace Umbraco.Web
}
}
+ ///
+ /// Checks if the xml cache file needs to be updated/persisted
+ ///
+ ///
+ ///
+ /// TODO: This needs an overhaul, see the error report created here:
+ /// https://docs.google.com/document/d/1neGE3q3grB4lVJfgID1keWY2v9JYqf-pw75sxUUJiyo/edit
+ ///
+ static void PersistXmlCache(HttpContextBase httpContext)
+ {
+ if (content.Instance.IsXmlQueuedForPersistenceToFile)
+ {
+ content.Instance.RemoveXmlFilePersistenceQueue();
+ content.Instance.PersistXmlToFile();
+ }
+ }
+
+ ///
+ /// Any object that is in the HttpContext.Items collection that is IDisposable will get disposed on the end of the request
+ ///
+ ///
+ private static void DisposeHttpContextItems(HttpContext http)
+ {
+ foreach (DictionaryEntry i in http.Items)
+ {
+ i.Value.DisposeIfDisposable();
+ i.Key.DisposeIfDisposable();
+ }
+ }
+
#region IHttpModule
///
@@ -469,18 +483,6 @@ namespace Umbraco.Web
#endregion
- ///
- /// Any object that is in the HttpContext.Items collection that is IDisposable will get disposed on the end of the request
- ///
- ///
- private static void DisposeHttpContextItems(HttpContext http)
- {
- foreach(var i in http.Items)
- {
- i.DisposeIfDisposable();
- }
- }
-
#region Events
internal static event EventHandler RouteAttempt;
private void OnRouteAttempt(RoutableAttemptEventArgs args)