November Happy Hour will be moved to Thursday December 5th.

ShouldExcludeContent not hitting breakpoint

EVT
EVT
Vote:
 

Following the instructions in geta-optimizely-sitemaps we have implemented additional logic in ShouldExcludeContent method but when running the Generate search engine sitemaps job no break-points in this override are hit and the logic written in here does not apply. 

Anyone else ran into this or has any ideas why that is so?

#303810
Jun 20, 2023 12:24
Vote:
 

have you registered it 

services.AddTransient<IContentFilter, SiteContentFilter>();

#303811
Jun 20, 2023 12:33
EVT - Jun 20, 2023 12:40
Yes I have
Vote:
 

I did a (very) quick look at the repository you linked, and it seems the default implementation is registered like this https://github.com/Geta/geta-optimizely-sitemaps/blob/59625a6952ef01209f860285ae86f1eac2f2d61d/src/Geta.Optimizely.Sitemaps/ServiceCollectionExtensions.cs#LL45C57-L45C57

and it seems you need to override the default implementation. i.e. your registration needs to be after AddSitemaps

You probably want to make your registration Singleton as well

#303813
Jun 20, 2023 12:46
EVT
Vote:
 

I have noticed that it was singeton in the default implementation, tested singleton, no difference. 

It is an override 

not sure what you mean with "after AddSitemaps", is it this?

#303817
Edited, Jun 20, 2023 13:00
Vote:
 

I meant something like this

services.AddSiteMaps();

services.AddSingleton<IContentFilter, GetaSiteMapContentFilter>();

the default implementation is registered in AddSiteMaps, so yours needs to be registered after to override it (not the override method as you thought) :)

#303820
Jun 20, 2023 13:06
EVT
Vote:
 

Removed registration from DependencyExtensions and added in Startup in the suggested order and it worked. 

Kept the transient though.

Thank you

#303823
Jun 20, 2023 13:27
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.