Is it possible to access the redirect manager from code?
Hi all.
Using Umbraco 8.5.3 and SeoChecker 2.9.0.
I was wondering if it was possible to access all redirect urls?
My scenario is that i use a custom 404 IContentFinder for only specific segments. i still use seoChecker redirect for these segments and SeoCheckers LastChanceFinder 404 for all other content.
public class MyCustomContentFinder : IContentFinder
{
private readonly ILogger _logger;
private readonly ISettingsService _settingsService; // Custom service
public MyCustomContentFinder(ILogger logger, ISettingsService settingsService)
{
_logger = logger;
_settingsService = settingsService;
}
public bool TryFindContent(PublishedRequest frequest)
{
try
{
if (frequest.UmbracoContext != null && frequest.UmbracoContext.InPreviewMode)
{
return frequest.PublishedContent != null;
}
if (frequest.Uri.LocalPath.ToLower().StartsWith("/activities/"))
{
/*
* Here i want to find urls from the SeoChecker redirects that match frequest.Uri.LocalPath
* If none of the urls match i continue to next step.
* If a url is found i set frequest.PublishedContent to null. or simply do nothing. Depends on what the redirect can get me.
*/
// This part works.
var content = frequest.UmbracoContext.Content.GetByRoute("/");
var notfoundDocument = _settingsService.Get404NotFoundCustomPage(content, frequest.Culture.Name);
if (notfoundDocument != null)
{
frequest.PublishedContent = frequest.UmbracoContext.Content.GetById(notfoundDocument.Id);
}
}
}
catch (Exception ex)
{
_logger.Error<MyCustomContentFinder>(ex, "Black magic!");
}
return frequest.PublishedContent != null;
}
}
i tried to convert the redirect property on a document to SEOChecker.Model.RedirectManagement.RedirectOverviewItem but it is only taking the last added redirect.
Is it possible to access the redirect manager from code?
Hi all.
Using Umbraco 8.5.3 and SeoChecker 2.9.0.
I was wondering if it was possible to access all redirect urls?
My scenario is that i use a custom 404
IContentFinder
for only specific segments. i still use seoChecker redirect for these segments and SeoCheckers LastChanceFinder 404 for all other content.i tried to convert the redirect property on a document to
SEOChecker.Model.RedirectManagement.RedirectOverviewItem
but it is only taking the last added redirect.You can use the RedirectsRepository.Instance.GetAll() methods maybe?
Great, that worked.
is working on a reply...