Fixes #U4-2058

This commit is contained in:
Shannon Deminick
2013-04-12 00:30:45 +06:00
parent a010448ad1
commit 14f71c9059

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Linq;
@@ -90,7 +91,17 @@ namespace umbraco.BasePages
{
get
{
return HttpContext.Current.CurrentHandler as BasePage;
var page = HttpContext.Current.CurrentHandler as BasePage;
if (page != null) return page;
//the current handler is not BasePage but people might be expecting this to be the case if they
// are using this singleton accesor... which is legacy code now and shouldn't be used. When people
// start using Umbraco.Web.UI.Pages.BasePage then this will not be the case! So, we'll just return a
// new instance of BasePage as a hack to make it work.
if (HttpContext.Current.Items["umbraco.BasePages.BasePage"] == null)
{
HttpContext.Current.Items["umbraco.BasePages.BasePage"] = new BasePage();
}
return (BasePage)HttpContext.Current.Items["umbraco.BasePages.BasePage"];
}
}