Firefox for Mac has a problem handling .ashx for PDF files, Sitecore

public class MediaHandler: MediaRequestHandler {

    public override void ProcessRequest(HttpContext context) {




    private static void DeterminePDFRequest(HttpContext context) {

        MediaRequest request = MediaManager.ParseMediaRequest(context.Request);

        if (request != null) {
            Media media = MediaManager.GetMedia(request.MediaUri);

            if (media != null) {
                Item item = media.MediaData.MediaItem;
                MediaItem mediaItem = media.MediaData.MediaItem;

                if (mediaItem != null) {

                    if (context.Request.UserAgent != null) {
                        if (mediaItem.Extension != "pdf") return;

                        string requestedUrl = context.Items["SC_REQUEST_MEASUREMENT_URL"].ToString();

                        if (!requestedUrl.Contains(".pdf")) {

                            MediaUrlOptions mediaUrlOptions = new MediaUrlOptions {
                                AbsolutePath = true, DisableMediaCache = true, DisableBrowserCache = true

                            string url = StringUtil.EnsurePrefix('/', MediaManager.GetMediaUrl(mediaItem, mediaUrlOptions));
                            url = url.Replace(".ashx", ".pdf");
                            QueryString queryString = new QueryString(url);



make sure to replace and update verb=”*” path=”sitecore_media.ashx” in web.config to use your MediaHandler

    <add verb="*" path="sitecore_media.ashx" type="Website.logic.Helper.MediaHandler, Website" name="Sitecore.MediaRequestHandler" />
    <add verb="*" path="sitecore_media.ashx" type="Website.logic.Helper.MediaHandler, Website"/>

2 thoughts on “Firefox for Mac has a problem handling .ashx for PDF files, Sitecore

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s