From 0566ef0dc6e59820da72db373732397825ddb4bf Mon Sep 17 00:00:00 2001 From: Jeavon Date: Mon, 21 Oct 2019 13:41:09 +0100 Subject: [PATCH 1/2] Add UmbracoVirtualNodeByUdiRouteHandler --- .../UmbracoVirtualNodeByUdiRouteHandler.cs | 27 +++++++++++++++++++ src/Umbraco.Web/Umbraco.Web.csproj | 1 + 2 files changed, 28 insertions(+) create mode 100644 src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs diff --git a/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs b/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs new file mode 100644 index 000000000000..0171f0c9cc82 --- /dev/null +++ b/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs @@ -0,0 +1,27 @@ +using System.Web.Routing; +using Umbraco.Core; +using Umbraco.Core.Models.PublishedContent; + +namespace Umbraco.Web.Mvc +{ + public class UmbracoVirtualNodeByUdiRouteHandler : UmbracoVirtualNodeRouteHandler + { + private readonly Udi _realNodeUdi; + + public UmbracoVirtualNodeByUdiRouteHandler(Udi realNodeUdi) + { + _realNodeUdi = realNodeUdi; + } + + protected sealed override IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext) + { + var byId = umbracoContext.Content.GetById(_realNodeUdi); + return byId == null ? null : FindContent(requestContext, umbracoContext, byId); + } + + protected virtual IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext, IPublishedContent baseContent) + { + return baseContent; + } + } +} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index e04adc9e84f1..9de612934484 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -250,6 +250,7 @@ + From 1d715dce97b61eda2d8af71d89cf44fc191f8e4a Mon Sep 17 00:00:00 2001 From: Jeavon Date: Mon, 21 Oct 2019 17:28:01 +0100 Subject: [PATCH 2/2] Parameter must be a GuidUdi --- src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs b/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs index 0171f0c9cc82..a1ee6c732a67 100644 --- a/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs +++ b/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs @@ -8,7 +8,7 @@ public class UmbracoVirtualNodeByUdiRouteHandler : UmbracoVirtualNodeRouteHandle { private readonly Udi _realNodeUdi; - public UmbracoVirtualNodeByUdiRouteHandler(Udi realNodeUdi) + public UmbracoVirtualNodeByUdiRouteHandler(GuidUdi realNodeUdi) { _realNodeUdi = realNodeUdi; }