4

I have written a custom processor in Sitecore to set the context language and country code. I am calling this processor on httpRequestBegin pipeline. The problem I am facing is that the processor is executing multiple times on page load for each component load. Below is my patch config file:

<httpRequestBegin>
  <processor patch:after="*[@type='Sitecore.Pipelines.HttpRequest.FileResolver, Sitecore.Kernel']" type="custom-processor class, custom-processor" />   
</httpRequestBegin>

Now I want to restrict my processor to execute only one time on page load and not on each component laod.

Please let me know how can I do this.

3

It's probably executing several times because your page may also have other Sitecore assets like images that it's downloading. This means that the httpBeginRequest will be called since it gets triggered all the time through the HttpApplication.BeginRequest. So, it's OK that it gets called all the time but you may want to do some checks first to make sure that the core of your processor only gets executed once or even for specific types of requests only.

5
  • What is way to check in Pipeline that will execute the processor for only specfic type of requests Feb 1 '18 at 17:02
  • Can i add the custom header to response and then check it next time if the value is present then do not execute some kind of that Feb 1 '18 at 17:34
  • You can use the template ID (name) so it only execute for those types of pages. You don't really want the header since the system doesn't really know that a particular request is triggered by another request (page). Plus, that header may not be there for the other requests (images, etc.). If you probably post another question with details on what your criteria is for executing it only once, that might help.
    – Marco
    Feb 1 '18 at 17:41
  • We need to have pipeline which hits first time when user access the URL of site . Pipeline will get the User location from GeoIP Module and set the language code for that country and this has to be done only once in beginning while searching we do not want pipeline to be executed and search is just a text box no template Feb 1 '18 at 19:59
  • Sounds like you can just populate a session variable and check it if it's set.
    – Marco
    Feb 1 '18 at 20:13
0

Try the initialize pipeline instead.

<pipelines> <initialize> <processor type="xxx" patch:after="processor[@type='Sitecore.Pipelines.Loader.EnsureAnonymousUsers, Sitecore.Kernel']" /> </initialize> </pipelines>

2
  • 3
    This only runs once ever at application startup, not per user request.
    – jammykam
    Jan 31 '18 at 15:50
  • This is not working for us we need to have pipeline which hits first time when user access the URL of site . Pipeline will get the User location from GeoIP Module and set the language code for that country and this has to be done only once in beginning. Feb 1 '18 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.