diff --git a/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs
index df7e1d9d09..0e360bae58 100644
--- a/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs
@@ -40,21 +40,6 @@ namespace Umbraco.Tests.PublishedContent
Assert.IsFalse(result);
}
- [Test]
- public void ConfigureRequest_Adds_HttpContext_Items_When_Published_Content_Assigned()
- {
- var umbracoContext = GetUmbracoContext("/test");
- var publishedRouter = CreatePublishedRouter();
- var request = publishedRouter.CreateRequest(umbracoContext);
- var content = GetPublishedContentMock();
- request.PublishedContent = content.Object;
- request.Culture = new CultureInfo("en-AU");
- publishedRouter.ConfigureRequest(request);
-
- Assert.AreEqual(1, umbracoContext.HttpContext.Items["pageID"]);
- Assert.AreEqual(request.UmbracoPage.Elements.Count, ((Hashtable) umbracoContext.HttpContext.Items["pageElements"]).Count);
- }
-
[Test]
public void ConfigureRequest_Sets_UmbracoPage_When_Published_Content_Assigned()
{
diff --git a/src/Umbraco.Web/Editors/MacroController.cs b/src/Umbraco.Web/Editors/MacroController.cs
index d625e3a575..3c576befb9 100644
--- a/src/Umbraco.Web/Editors/MacroController.cs
+++ b/src/Umbraco.Web/Editors/MacroController.cs
@@ -135,7 +135,6 @@ namespace Umbraco.Web.Editors
var legacyPage = new global::umbraco.page(doc, _variationContextAccessor);
- UmbracoContext.HttpContext.Items["pageID"] = doc.Id;
UmbracoContext.HttpContext.Items["pageElements"] = legacyPage.Elements;
UmbracoContext.HttpContext.Items[global::Umbraco.Core.Constants.Conventions.Url.AltTemplate] = null;
diff --git a/src/Umbraco.Web/Routing/PublishedRouter.cs b/src/Umbraco.Web/Routing/PublishedRouter.cs
index 42137d3b9e..c8a66aa076 100644
--- a/src/Umbraco.Web/Routing/PublishedRouter.cs
+++ b/src/Umbraco.Web/Routing/PublishedRouter.cs
@@ -211,7 +211,6 @@ namespace Umbraco.Web.Routing
frequest.UmbracoPage = new page(frequest);
// used by many legacy objects
- frequest.UmbracoContext.HttpContext.Items["pageID"] = frequest.PublishedContent.Id;
frequest.UmbracoContext.HttpContext.Items["pageElements"] = frequest.UmbracoPage.Elements;
return true;
@@ -257,8 +256,7 @@ namespace Umbraco.Web.Routing
// handlers like default.aspx will want it and most macros currently need it
request.UmbracoPage = new page(request);
- // these two are used by many legacy objects
- request.UmbracoContext.HttpContext.Items["pageID"] = request.PublishedContent.Id;
+ // this is used by many legacy objects
request.UmbracoContext.HttpContext.Items["pageElements"] = request.UmbracoPage.Elements;
}
diff --git a/src/Umbraco.Web/Templates/TemplateRenderer.cs b/src/Umbraco.Web/Templates/TemplateRenderer.cs
index f2fe2f9a80..e0b5c8c301 100644
--- a/src/Umbraco.Web/Templates/TemplateRenderer.cs
+++ b/src/Umbraco.Web/Templates/TemplateRenderer.cs
@@ -202,7 +202,6 @@ namespace Umbraco.Web.Templates
// handlers like default.aspx will want it and most macros currently need it
request.UmbracoPage = new page(request);
//now, set the new ones for this page execution
- _umbracoContext.HttpContext.Items["pageID"] = request.PublishedContent.Id;
_umbracoContext.HttpContext.Items["pageElements"] = request.UmbracoPage.Elements;
_umbracoContext.HttpContext.Items[Core.Constants.Conventions.Url.AltTemplate] = null;
_umbracoContext.PublishedRequest = request;
@@ -214,8 +213,8 @@ namespace Umbraco.Web.Templates
private void SaveExistingItems()
{
//Many objects require that these legacy items are in the http context items... before we render this template we need to first
- //save the values in them so that we can re-set them after we render so the rest of the execution works as per normal.
- _oldPageId = _umbracoContext.HttpContext.Items["pageID"];
+ //save the values in them so that we can re-set them after we render so the rest of the execution works as per normal
+ _oldPageId = _umbracoContext.PageId;
_oldPageElements = _umbracoContext.HttpContext.Items["pageElements"];
_oldPublishedRequest = _umbracoContext.PublishedRequest;
_oldAltTemplate = _umbracoContext.HttpContext.Items[Umbraco.Core.Constants.Conventions.Url.AltTemplate];
@@ -227,7 +226,6 @@ namespace Umbraco.Web.Templates
private void RestoreItems()
{
_umbracoContext.PublishedRequest = _oldPublishedRequest;
- _umbracoContext.HttpContext.Items["pageID"] = _oldPageId;
_umbracoContext.HttpContext.Items["pageElements"] = _oldPageElements;
_umbracoContext.HttpContext.Items[Umbraco.Core.Constants.Conventions.Url.AltTemplate] = _oldAltTemplate;
}
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index abcff8ffe9..f85ba9b494 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -1409,9 +1409,6 @@
nodeSorter.asmx
Component
-
- ASPXCodeBehind
-
diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs
index 198721618d..831e3c5cdc 100644
--- a/src/Umbraco.Web/UmbracoContext.cs
+++ b/src/Umbraco.Web/UmbracoContext.cs
@@ -253,17 +253,15 @@ namespace Umbraco.Web
///
public int? PageId
{
- // TODO - this is dirty old legacy tricks, we should clean it up at some point
- // also, what is a "custom page" and when should this be either null, or different
- // from PublishedContentRequest.PublishedContent.Id ??
- // SD: Have found out it can be different when rendering macro contents in the back office, but really youshould just be able
- // to pass a page id to the macro renderer instead but due to all the legacy bits that's real difficult.
get
{
try
{
- //TODO: this should be done with a wrapper: http://issues.umbraco.org/issue/U4-61
- return int.Parse(HttpContext.Items["pageID"].ToString());
+ // This was changed but the comments used to refer to
+ // macros in the backoffice not working with this Id
+ // it's probably not a problem any more though. Old comment:
+ // https://github.com/umbraco/Umbraco-CMS/blob/7a615133ff9de84ee667fb7794169af65e2b4d7a/src/Umbraco.Web/UmbracoContext.cs#L256
+ return Current.PublishedRequest.PublishedContent.Id;
}
catch
{
diff --git a/src/Umbraco.Web/umbraco.presentation/page.cs b/src/Umbraco.Web/umbraco.presentation/page.cs
index a1da34d46e..ac35c336b2 100644
--- a/src/Umbraco.Web/umbraco.presentation/page.cs
+++ b/src/Umbraco.Web/umbraco.presentation/page.cs
@@ -3,18 +3,13 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using System.Web;
using System.Web.UI;
-using System.Xml;
using Umbraco.Core;
-using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web.Editors;
using Umbraco.Web.Routing;
-using Umbraco.Core.Configuration;
using Umbraco.Core.PropertyEditors;
-using Umbraco.Web;
using Umbraco.Web.Composing;
namespace umbraco
@@ -146,55 +141,7 @@ namespace umbraco
_elements.Add("path", path);
_elements.Add("splitpath", _splitpath);
}
-
- void populatePageData(XmlNode node)
- {
- string s;
- DateTime dt;
- Guid guid;
- int i;
-
- if (int.TryParse(attrValue(node, "id"), out i))
- _elements["pageID"] = this._pageId = i;
-
- if ((s = attrValue(node, "nodeName")) != null)
- _elements["pageName"] = this._pageName = s;
-
- if (int.TryParse(attrValue(node, "parentId"), out i))
- _elements["parentId"] = this._parentId = i;
-
- if (int.TryParse(attrValue(node, "nodeType"), out i))
- _elements["nodeType"] = this._nodeType = i;
- if ((s = attrValue(node, "nodeTypeAlias")) != null)
- _elements["nodeTypeAlias"] = this._nodeTypeAlias = s;
-
- if ((s = attrValue(node, "writerName")) != null)
- _elements["writerName"] = this._writerName = s;
- if ((s = attrValue(node, "creatorName")) != null)
- _elements["creatorName"] = this._creatorName = s;
-
- if (DateTime.TryParse(attrValue(node, "createDate"), out dt))
- _elements["createDate"] = this._createDate = dt;
- if (DateTime.TryParse(attrValue(node, "updateDate"), out dt))
- _elements["updateDate"] = this._updateDate = dt;
-
- if (Guid.TryParse(attrValue(node, "pageVersion"), out guid))
- _elements["pageVersion"] = this._pageVersion = guid;
-
- if ((s = attrValue(node, "path")) != null)
- {
- _elements["path"] = this._path = s;
- _elements["splitpath"] = this._splitpath = _path.Split(',');
- }
- }
-
- string attrValue(XmlNode node, string attributeName)
- {
- var attr = node.Attributes.GetNamedItem(attributeName);
- var value = attr != null ? attr.Value : null;
- return value;
- }
-
+
///
/// Puts the properties of the node into the elements table
///
@@ -217,42 +164,6 @@ namespace umbraco
}
}
}
-
- void populateElementData(XmlNode node)
- {
- string xpath = "./* [not(@isDoc)]";
-
- foreach (XmlNode data in node.SelectNodes(xpath))
- {
- // ignore empty elements
- if (data.ChildNodes.Count == 0)
- continue;
-
- string alias = data.Name;
- string value = data.FirstChild.Value;
-
- // moved to PublishedContentRequest + UmbracoModule
- //if (alias == "umbracoRedirect")
- //{
- // int i;
- // if (int.TryParse(value, out i))
- // HttpContext.Current.Response.Redirect(library.NiceUrl(int.Parse(data.FirstChild.Value)), true);
- //}
-
- if (_elements.ContainsKey(alias))
- {
- Current.Logger.Debug(
- string.Format("Aliases must be unique, an element with alias \"{0}\" has already been loaded!", alias));
- }
- else
- {
- _elements[alias] = value;
- Current.Logger.Debug(
- string.Format("Load element \"{0}\"", alias));
- }
- }
- }
-
#endregion
#region Public properties
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Web/UI/ContentPage.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Web/UI/ContentPage.cs
deleted file mode 100644
index de7d9574ae..0000000000
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/Web/UI/ContentPage.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-
-namespace umbraco.presentation.Web.UI
-{
- ///
- /// Summary description for ContentPage.
- ///
- public class ContentPage : System.Web.UI.Page
- {
- private int _id = 0;
-
- public int UmbracoNodeId
- {
- set
- {
- _id = value;
- System.Web.HttpContext.Current.Items["pageID"] = _id;
- }
- get {return _id;}
- }
- public ContentPage()
- {
- }
- }
-}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/Item.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/Item.cs
index 14b4824171..89a03a1437 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/Item.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/Item.cs
@@ -203,9 +203,9 @@ namespace umbraco.presentation.templateControls
return nodeIdInt;
}
}
- else if (PageElements["pageID"] != null)
+ else if (UmbracoContext.Current.PageId != null)
{
- return int.Parse(PageElements["pageID"].ToString());
+ return UmbracoContext.Current.PageId.Value;
}
return null;
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/Macro.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/Macro.cs
index 3635ab7eda..0d54ce2a02 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/Macro.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/Macro.cs
@@ -132,7 +132,7 @@ namespace umbraco.presentation.templateControls
// set pageId to int.MinValue if no pageID was found,
// e.g. if the macro was rendered on a custom (non-Umbraco) page
- var pageId = Context.Items["pageID"] == null ? int.MinValue : int.Parse(Context.Items["pageID"].ToString());
+ var pageId = UmbracoContext.Current.PageId == null ? int.MinValue : UmbracoContext.Current.PageId.Value;
if ((string.IsNullOrEmpty(Language) == false && Text != "") || string.IsNullOrEmpty(FileLocation) == false) {
var tempMacro = new MacroModel();