3

how to replace the existing media request handler with custom one in web.config with help of patch file,

existing handler in web.config:

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

my custom handler:

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

Thanks in advance.

4

It is not possible with patch files. You can use a patch file to customize the Sitecore configuration only. It means, it only patches what is inside the

<configuration>
  <sitecore>
  </sitecore>
</configuration>

You can read more about patching

For the web.config parts which are outside of the <sitecore> node, you can use Slowcheetah Transforms during your build and publish process ( https://www.google.com/search?q=slowcheetah+transforms ).

0

I always like to take opportunities like this to remind developers to never directly modify the web.config. This make upgrades more difficult. Always transform a new web.config out of the Sitecore default web.config.

For the request above, use this slowcheetah transform

<?xml version="1.0" encoding="utf-8"?>

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

    <system.webServer>
        <handlers>
            <add xdt:Transform="Replace" xdt:Locator="Match(name)" name="Sitecore.MediaRequestHandler" verb="*" path="sitecore_media.ashx" type="demo.Foundation.Sitecore.ExtendedMediaRequest.ExtendedMediaRequestHandler, demo.Foundation.Sitecore.ExtendedMediaRequest" />
        </handlers>
    </system.webServer>

</configuration>

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.