Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Darren Hunter 140 posts 232 karma points
    Nov 17, 2022 @ 16:56
    Darren Hunter
    0

    HTTP Request Intercept

    Hi,

    I am working on a site for a client that has a members area and I need a way to stop specific files from been downloaded by any one.

    I have been trying to use a controller to hijack http requesteds but it dose not seem to be working.

    Is there a way using IHttpHandler to intercept http reqest on download. I started to look at this but I am using the latest version of version 8 and it dose not seem to be hitting my custome media control. Even though I have registed the control using:

    composition.Register

    I just need to intercept the http request and check the file if it restricted or not. I know I can check using the media service to get the file propertys so that not a problem, the Issue I am having is I can't intercept any HTTP requests.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Nov 17, 2022 @ 17:27
    Huw Reddick
    0

    you will need to write an IHttpHandler

  • Darren Hunter 140 posts 232 karma points
    Nov 18, 2022 @ 08:32
    Darren Hunter
    0

    I have tried that but it not working, do I need to register it or should it just work out of the box??

    I can't find any thing in the documentation on how to register a IHttpHandler

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Nov 18, 2022 @ 17:32
    Huw Reddick
    0

    I'm away from my pc currently but will check what I did in the morning

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Nov 18, 2022 @ 17:34
    Huw Reddick
    0

    IIRC you register it in web.config

  • Conor Howe 36 posts 137 karma points
    Nov 19, 2022 @ 09:43
  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Nov 20, 2022 @ 14:40
    Huw Reddick
    0

    I had to change the web.config that is in the media folder, not the websites web.config

    My media folder web.config is like below

        <?xml version="1.0" encoding="UTF-8"?>
        <configuration>
          <system.webServer>
            <handlers>
              <clear />
              <add name="DOCX" path="*.docx" verb="*" type="MyApp.ProtectedMediaHttpHandler" />
              <add name="XLSX" path="*.xlsx" verb="*" type="MyApp.ProtectedMediaHttpHandler" />
              <add name="DOC" path="*.doc" verb="*" type="MyApp.ProtectedMediaHttpHandler" />
              <add name="XLS" path="*.xls" verb="*" type="MyApp.ProtectedMediaHttpHandler" />
              <add name="PDF" path="*.pdf" verb="*" type="MyApp.ProtectedMediaHttpHandler" />
              <add name="ZIP" path="*.zip" verb="*" type="MyApp.ProtectedMediaHttpHandler" />
              <add name="EPS" path="*.eps" verb="*" type="MyApp.ProtectedMediaHttpHandler" />
    .....
            </handlers>
          </system.webServer>
        </configuration>
    
Please Sign in or register to post replies

Write your reply to:

Draft