diff --git a/appveyor.yml b/appveyor.yml index d2ec2a9..768af2a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ image: Visual Studio 2017 # version format -version: 2.0.3.{build} +version: 2.0.4.{build} # UMBRACO_PACKAGE_PRERELEASE_SUFFIX if a rtm release build this should be blank, otherwise if empty will default to alpha # example UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta diff --git a/src/Our.Umbraco.StackedContent/Web/Controllers/StackedContentApiController.cs b/src/Our.Umbraco.StackedContent/Web/Controllers/StackedContentApiController.cs index 236cecd..3126139 100644 --- a/src/Our.Umbraco.StackedContent/Web/Controllers/StackedContentApiController.cs +++ b/src/Our.Umbraco.StackedContent/Web/Controllers/StackedContentApiController.cs @@ -33,8 +33,17 @@ public HttpResponseMessage GetPreviewMarkup([FromBody] JObject item, int pageId) // Ensure PublishedContentRequest exists, just in case there are any RTE Macros to render if (UmbracoContext.PublishedContentRequest == null) { + var pageUrl = page.UrlAbsolute(); + + // If the page is unpublished, then the URL will be empty or a hash '#'. + // Use the current request as a fallback, as we need to give the PublishedContentRequest a URI. + if (string.IsNullOrEmpty(pageUrl) || pageUrl.Equals("#")) + { + pageUrl = string.Concat(Request.RequestUri.GetLeftPart(UriPartial.Authority), "/#", pageId); + } + #pragma warning disable CS0618 // Type or member is obsolete - var pcr = new PublishedContentRequest(new Uri(page.UrlAbsolute()), UmbracoContext.RoutingContext); + var pcr = new PublishedContentRequest(new Uri(pageUrl), UmbracoContext.RoutingContext); #pragma warning restore CS0618 // Type or member is obsolete UmbracoContext.PublishedContentRequest = pcr;