Skip to main content
highlighted the code
Source Link
Sumit Bhatia
  • 5.9k
  • 2
  • 9
  • 25

The patch:insteadpatch:instead attribute is used to replace the existing Sitecore.MediaRequestHandlerSitecore.MediaRequestHandler processor in the initialize pipeline with your custom handler.

  1. Create a new patch file, for example, CustomMediaRequestHandler.configCustomMediaRequestHandler.config, in the App_Config/IncludeApp_Config/Include folder.

    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <sitecore>
        <pipelines>
          <initialize>
            <processor type="example.example.example.Processors.CustomMediaRequestHandler, example.example.Redirects" patch:instead="processor[@type='Sitecore.Resources.Media.MediaRequestHandler, Sitecore.Kernel']"/>
          </initialize>
        </pipelines>
      </sitecore>
    </configuration>
    

2.If your handler configuration is under the section<handlers> section, you can use the following XML structure:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <system.webServer>
    <handlers>
      <add verb="*" path="sitecore_media.ashx" type="example.example.example.Processors.CustomMediaRequestHandler, example.example.Redirects" name="Sitecore.MediaRequestHandler" patch:instead="add[@name='Sitecore.MediaRequestHandler']"/>
    </handlers>
  </system.webServer>
</configuration>

Hope this help!

The patch:instead attribute is used to replace the existing Sitecore.MediaRequestHandler processor in the initialize pipeline with your custom handler.

  1. Create a new patch file, for example, CustomMediaRequestHandler.config, in the App_Config/Include folder.

    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <sitecore>
        <pipelines>
          <initialize>
            <processor type="example.example.example.Processors.CustomMediaRequestHandler, example.example.Redirects" patch:instead="processor[@type='Sitecore.Resources.Media.MediaRequestHandler, Sitecore.Kernel']"/>
          </initialize>
        </pipelines>
      </sitecore>
    </configuration>
    

2.If your handler configuration is under the section, you can use the following XML structure:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <system.webServer>
    <handlers>
      <add verb="*" path="sitecore_media.ashx" type="example.example.example.Processors.CustomMediaRequestHandler, example.example.Redirects" name="Sitecore.MediaRequestHandler" patch:instead="add[@name='Sitecore.MediaRequestHandler']"/>
    </handlers>
  </system.webServer>
</configuration>

Hope this help!

The patch:instead attribute is used to replace the existing Sitecore.MediaRequestHandler processor in the initialize pipeline with your custom handler.

  1. Create a new patch file, for example, CustomMediaRequestHandler.config, in the App_Config/Include folder.

    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <sitecore>
        <pipelines>
          <initialize>
            <processor type="example.example.example.Processors.CustomMediaRequestHandler, example.example.Redirects" patch:instead="processor[@type='Sitecore.Resources.Media.MediaRequestHandler, Sitecore.Kernel']"/>
          </initialize>
        </pipelines>
      </sitecore>
    </configuration>
    

2.If your handler configuration is under the <handlers> section, you can use the following XML structure:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <system.webServer>
    <handlers>
      <add verb="*" path="sitecore_media.ashx" type="example.example.example.Processors.CustomMediaRequestHandler, example.example.Redirects" name="Sitecore.MediaRequestHandler" patch:instead="add[@name='Sitecore.MediaRequestHandler']"/>
    </handlers>
  </system.webServer>
</configuration>

Hope this help!

Source Link

The patch:instead attribute is used to replace the existing Sitecore.MediaRequestHandler processor in the initialize pipeline with your custom handler.

  1. Create a new patch file, for example, CustomMediaRequestHandler.config, in the App_Config/Include folder.

    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <sitecore>
        <pipelines>
          <initialize>
            <processor type="example.example.example.Processors.CustomMediaRequestHandler, example.example.Redirects" patch:instead="processor[@type='Sitecore.Resources.Media.MediaRequestHandler, Sitecore.Kernel']"/>
          </initialize>
        </pipelines>
      </sitecore>
    </configuration>
    

2.If your handler configuration is under the section, you can use the following XML structure:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <system.webServer>
    <handlers>
      <add verb="*" path="sitecore_media.ashx" type="example.example.example.Processors.CustomMediaRequestHandler, example.example.Redirects" name="Sitecore.MediaRequestHandler" patch:instead="add[@name='Sitecore.MediaRequestHandler']"/>
    </handlers>
  </system.webServer>
</configuration>

Hope this help!