Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit b8e78da

Browse files
committed
fixed wrongly generated PublishedRequest
1 parent 9a13c1a commit b8e78da

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Umbraco.Web.Editors;
2020
using Umbraco.Web.Mvc;
2121
using Umbraco.Web.PublishedCache;
22+
using Umbraco.Web.Routing;
2223

2324
namespace Our.Umbraco.DocTypeGridEditor.Web.Controllers
2425
{
@@ -149,13 +150,21 @@ public HttpResponseMessage GetPreviewMarkup([FromBody] PreviewData data, [FromUr
149150
}
150151
}
151152

153+
if (UmbracoContext.PublishedRequest == null)
154+
{
155+
var router = Current.Factory.GetInstance(typeof(IPublishedRouter)) as IPublishedRouter;
156+
UmbracoContext.PublishedRequest = router.CreateRequest(UmbracoContext, Request.RequestUri);
157+
UmbracoContext.PublishedRequest.PublishedContent = page;
158+
}
159+
152160
// Set the culture for the preview
153161
if (page != null)
154162
{
155163
var currentCulture = page.GetCultureFromDomains();
156164
if (page.Cultures != null && page.Cultures.ContainsKey(currentCulture))
157165
{
158166
var culture = new CultureInfo(page.Cultures[currentCulture].Culture);
167+
UmbracoContext.PublishedRequest.Culture = culture;
159168
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
160169
System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
161170
}
@@ -176,7 +185,7 @@ public HttpResponseMessage GetPreviewMarkup([FromBody] PreviewData data, [FromUr
176185

177186
// Render view
178187
var partialName = "~/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditorPreviewer.cshtml";
179-
var markup = Helpers.ViewHelper.RenderPartial(partialName, model, UmbracoContext.HttpContext);
188+
var markup = Helpers.ViewHelper.RenderPartial(partialName, model, UmbracoContext.HttpContext, UmbracoContext);
180189

181190
// Return response
182191
var response = new HttpResponseMessage

0 commit comments

Comments
 (0)