Fixes RedirectToUmbracoPageResult to handle redirects to pages with domains defined on them (#12259)

* Fixes RedirectToUmbracoPageResult to handle redirects to pages with domains defined on them.

* Renamed variable to match with updated service type.

* Apply suggestions from code review

Co-authored-by: Ronald Barendse <ronald@barend.se>

* Fixed usage of IUrlHelper.

Co-authored-by: Ronald Barendse <ronald@barend.se>
This commit is contained in:
Andy Butland
2022-04-19 08:13:24 +02:00
committed by GitHub
parent 6519b88dfc
commit 68353f9d06

View File

@@ -2,9 +2,9 @@ using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Web;
@@ -122,8 +122,9 @@ namespace Umbraco.Cms.Web.Website.ActionResults
}
HttpContext httpContext = context.HttpContext;
IIOHelper ioHelper = httpContext.RequestServices.GetRequiredService<IIOHelper>();
string destinationUrl = ioHelper.ResolveUrl(Url);
IUrlHelperFactory urlHelperFactory = httpContext.RequestServices.GetRequiredService<IUrlHelperFactory>();
IUrlHelper urlHelper = urlHelperFactory.GetUrlHelper(context);
string destinationUrl = urlHelper.Content(Url);
if (_queryString.HasValue)
{
@@ -134,6 +135,5 @@ namespace Umbraco.Cms.Web.Website.ActionResults
return Task.CompletedTask;
}
}
}