0

We have created a custom pipeline to append extra header details for PDFs. This works well on our local boxes however when we push the code to our UAT server hosted on Azure the pipeline is not called.

I have checked ShowConfig.aspx and the patch config file has been added.

Aare there any other ways to work out why its not being called when we push it to Azure. Other custom pipelines in the project still work and we can't figure out why this one doesn't.

We also added logging however the log file is never populated, which tells me the class is never ran

An example of the class is as followed:

public class MediaRequestHeaderProcessor
{

    public void Process(MediaRequestHeadersArgs args)
    {

        Assert.ArgumentNotNull(args, nameof(args));
        var media = args.Media;
        var headers = args.Context.Response.Headers;
        

        if (Context.Database != null)
        {

            if (media != null)
            {
                var item = Context.Database.GetItem(media.MediaData.MediaItem.ID);

                if (item != null)
                {
                    headers.Add("X-Robots-Tag", "noindex");

                }

            }

        }
    }
}

Patch file:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
   <pipelines>
      <mediaRequestHeaders>
        <processor type="Project.Feature.ResponseHeaders.Pipelines.MediaRequestHeaderProcessor, Project.Feature.ResponseHeaders" />
      </mediaRequestHeaders>
    </pipelines>
  </sitecore>
</configuration>

On the Azure CM and CD server the patch file is present and so is the DLL. I've used dotPeek and the code in the DLL project matches my example above

6
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Richard Seal
    Jul 9, 2021 at 15:23
  • Add some logs within your conditions. So you know if your code is being executed with wrong args (if Context.Database, media and item are null, you should investigate.) Jul 11, 2021 at 22:56
  • @Jean-Nicolas G Yes we tried that and the code is never hit as mentioned in my post :)
    – James
    Jul 12, 2021 at 8:01
  • And your files were properly deployed in both the cm and cds ? Like can you confirm you can see the dll and that within the dll you can see the MediaRequestHeaderProcessor ? Jul 12, 2021 at 16:16
  • All Files are as expected, just checked
    – James
    Jul 13, 2021 at 9:50

1 Answer 1

0

As suggested by Cristi Vulturar

I looked to see if the Media Request handler was correctly setup. This let me to the Web config file on our UAT Server

I found while comparing my local to the UAT server that the hander set up: <add verb="*" path="sitecore_media.ashx" was looking at Sitecore.Resources.Media.MediaRequestHandler rather than Sitecore.XA.Foundation.MediaRequestHandler.MediaRequestHandler, Sitecore.XA.Foundation.MediaRequestHandler

So my change was: Old

<add verb="*" path="sitecore_media.ashx" type="Sitecore.Resources.Media.MediaRequestHandler, Sitecore.Kernel" name="Sitecore.MediaRequestHandler" />

New

<add verb="*" path="sitecore_media.ashx" type="Sitecore.XA.Foundation.MediaRequestHandler.MediaRequestHandler, Sitecore.XA.Foundation.MediaRequestHandler" name="Sitecore.MediaRequestHandler" />

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.