+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Custom handler for mp3 files IIS7

Custom handler for mp3 files IIS7

3 posts, 0 answered
  1. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    31 Jan 2011
    Link to this post
    Hi support,

    I converting my site to Sitefinity 3.7 SP4, running on .NET 4.0
    I'm having some troubles to enable the direct access to .mp3 files.

    I use this javascript for use inside my FlowPlayer module:

    <script type='text/javascript'>
       var fpStill='/egz/Assets/Images/media-placeholder.jpg';
       var fpPlayer='/egz/Assets/Flowplayer/flowplayer.commercial-3.1.5.swf';
       var fpSource='/egz/Media/Preken/audio_file.mp3';
       var fpPlayerAudio='/egz/Assets/Flowplayer/flowplayer.audio-3.1.2.swf';
       var fpPlayerContent='/egz/Assets/Flowplayer/flowplayer.content-3.1.0.swf';
    </script>

    If I copy/paste the value of fpSource in my URL it won't work.

    I use this custom handler:
    public class CustomCmsContentHandler : ContentHttpHandler
    {
        protected override object ProcessContentItem(IContent content, HttpRequest request)
        {
            string extension = VirtualPathUtility.GetExtension(HttpContext.Current.Request.Url.AbsolutePath);
            if (extension.Equals("*.mp3", StringComparison.OrdinalIgnoreCase) && !content.MimeType.StartsWith("audio/"))
            {
                throw new HttpException(404, "Not found");
            }
      
            return base.ProcessContentItem(content, HttpContext.Current.Request);
        }
    }

    I registered this line in my <httpHandlers>
    <add verb="GET" path="*.mp3" type="CustomCmsContentHandler, App_Code"/>

    And I registered this line in my <httpHandlers> under <system.webserver>
    <add name="mp3Handler" path="*.mp3" verb="GET" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness32"/>

    The site is running under .NET 4.0 Integrated mode.
    Did I forgot something to registrer?

    Where or what should I add into my web.config to get it working?

    Regards,
    Daniel
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    01 Feb 2011
    Link to this post
    Hello Daniel,

    In the handler where you reference aspnet_isapi I can see that you are referencing the .NET 2.0 version of this assembly. Can you please try referencing the .NET 4.0 one?

    All the best,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    01 Feb 2011
    Link to this post
    I removed the line from the web.config and added the handler from IIS7. Don't know if that is the right way, but it worked.
    I was not sure about what to fill in inside the 'Type' field, so I added the same value as for the IIS6 configuration, that is: 'CustomCmsContentHandler, App_Code'.

    Well, it works. If it should be different, I'd like to hear! :)

    Thanks,
    Daniel
Register for webinar
3 posts, 0 answered