DefaultUrlProvider not running GetUrl() override on all requests; cached values being used
Hi,
We have an implementation of DefaultUrlProvider registered in our Umbraco 10.6.1 website. The problem we are facing is that the overridden GetUrl() method we have implemented only ever seems to get run when the application is started, or when any content is published. As a result, the previously overridden URL values are retrieved from the publishedValueFallback passed into the constructor, from when the application was last started or when any content was published.
Startup.cs:
builder.UrlProviders().Insert<OurUrlProvider>(0);
OurUrlProvider.cs:
public OurUrlProvider(IOurUrlProviderService ourUrlParserService, IOptionsMonitor<global::Umbraco.Cms.Core.Configuration.Models.RequestHandlerSettings> requestSettings, ILogger<DefaultUrlProvider> logger, ISiteDomainMapper siteDomainMapper, IUmbracoContextAccessor umbracoContextAccessor, UriUtility uriUtility, global::Umbraco.Cms.Core.Services.ILocalizationService localizationService) : base(requestSettings, logger, siteDomainMapper, umbracoContextAccessor, uriUtility, localizationService)
{
_ourUrlProviderService = ourUrlParserService;
}
public override UrlInfo GetUrl(IPublishedContent content, UrlMode mode, string culture, Uri current)
{
var baseUrl = base.GetUrl(content, mode, culture, current);
if (content == null)
{
return baseUrl;
}
// logic to append IDs to URLs in links is done in this DI'd service
var newUrl = _ourUrlProviderService.GetUrl(baseUrl);
return newUrl;
}
Some snippets from one of the generated models that is affected by this issue (constructor, and one of the properties where we would expect the links to be overridden by the DefaultUrlProvider middleware:
Home.generated.cs (putting a breakpoint in this constructor and hitting the Home controller shows that the publishedValueFallback values are being used):
One of the properties that we would expect to be transformed by the DefaultUrlProvider (our OverrideableBlockListModel inherits from a collection of Umbraco's BlockListItem):
Is there any way to tell our models to not use the PublishedValueFallback? Or is there something missing in the setup of the DefaultUrlProvider middleware? Any help would be greatly appreciated!
DefaultUrlProvider not running GetUrl() override on all requests; cached values being used
Hi,
We have an implementation of DefaultUrlProvider registered in our Umbraco 10.6.1 website. The problem we are facing is that the overridden GetUrl() method we have implemented only ever seems to get run when the application is started, or when any content is published. As a result, the previously overridden URL values are retrieved from the publishedValueFallback passed into the constructor, from when the application was last started or when any content was published.
Startup.cs:
OurUrlProvider.cs:
Some snippets from one of the generated models that is affected by this issue (constructor, and one of the properties where we would expect the links to be overridden by the DefaultUrlProvider middleware:
Home.generated.cs (putting a breakpoint in this constructor and hitting the Home controller shows that the publishedValueFallback values are being used):
One of the properties that we would expect to be transformed by the DefaultUrlProvider (our OverrideableBlockListModel inherits from a collection of Umbraco's BlockListItem):
Is there any way to tell our models to not use the PublishedValueFallback? Or is there something missing in the setup of the DefaultUrlProvider middleware? Any help would be greatly appreciated!
Thanks
is working on a reply...