merge with 6.1.0
This commit is contained in:
@@ -29,6 +29,7 @@ namespace Umbraco.Web
|
||||
private const string HttpContextItemName = "Umbraco.Web.UmbracoContext";
|
||||
private static readonly object Locker = new object();
|
||||
|
||||
private bool _replacing;
|
||||
private PreviewContent _previewContent;
|
||||
|
||||
/// <summary>
|
||||
@@ -78,8 +79,12 @@ namespace Umbraco.Web
|
||||
/// </remarks>
|
||||
public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, bool replaceContext)
|
||||
{
|
||||
if (UmbracoContext.Current != null && !replaceContext)
|
||||
return UmbracoContext.Current;
|
||||
if (UmbracoContext.Current != null)
|
||||
{
|
||||
if (!replaceContext)
|
||||
return UmbracoContext.Current;
|
||||
UmbracoContext.Current._replacing = true;
|
||||
}
|
||||
|
||||
var umbracoContext = new UmbracoContext(
|
||||
httpContext,
|
||||
@@ -179,9 +184,9 @@ namespace Umbraco.Web
|
||||
lock (Locker)
|
||||
{
|
||||
//if running in a real HttpContext, this can only be set once
|
||||
if (System.Web.HttpContext.Current != null && Current != null)
|
||||
if (System.Web.HttpContext.Current != null && Current != null && !Current._replacing)
|
||||
{
|
||||
throw new ApplicationException("The current httpContext can only be set once during a request.");
|
||||
throw new ApplicationException("The current UmbracoContext can only be set once during a request.");
|
||||
}
|
||||
|
||||
//if there is an HttpContext, return the item
|
||||
|
||||
Reference in New Issue
Block a user