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

Commit 67fe321

Browse files
authored
Fix issue with umbracoRedirect and dtgePreview
Hook into the request pipeline to stop redirects for DTGE preview requests
1 parent a700957 commit 67fe321

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Umbraco.Core.Events;
66
using Umbraco.Core.Models;
77
using Umbraco.Core.Services;
8+
using Umbraco.Web.Routing;
89

910
namespace Our.Umbraco.DocTypeGridEditor
1011
{
@@ -24,6 +25,18 @@ protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplica
2425
{
2526
DataTypeService.Saved += ExpireDataTypeCache;
2627
ContentTypeService.SavedContentType += ExpireContentTypeCache;
28+
PublishedContentRequest.Prepared += PublishedContentRequest_Prepared;
29+
}
30+
31+
private void PublishedContentRequest_Prepared(object sender, EventArgs e)
32+
{
33+
var request = sender as PublishedContentRequest;
34+
// Check if it's a dtgePreview request and is set to redirect.
35+
// If so reset the redirect url to an empty string to stop the redirect happening in preview mode.
36+
if (request.Uri.Query.Contains("dtgePreview") && request.IsRedirect)
37+
{
38+
request.SetRedirect(string.Empty);
39+
}
2740
}
2841

2942
private void ExpireDataTypeCache(IDataTypeService sender, SaveEventArgs<IDataTypeDefinition> e)

0 commit comments

Comments
 (0)