Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to restrict image folder from direct access

how to restrict image folder from direct access

Scheduled Pinned Locked Moved ASP.NET
helptutorial
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Neeraj Arora
    wrote on last edited by
    #1

    Hi All, I've a image gallery website where members can upload and restrict the access to few friends. The problem is, images are directly accessible from browser. How could I restrict specific folder to accessible from aspx pages only. Regards, Neeraj

    A N N 3 Replies Last reply
    0
    • N Neeraj Arora

      Hi All, I've a image gallery website where members can upload and restrict the access to few friends. The problem is, images are directly accessible from browser. How could I restrict specific folder to accessible from aspx pages only. Regards, Neeraj

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      I have done similar to this.. I have used a webservice to get the path of the requested images from an encrypted session guid which is created during login...

      Abhishek Sur

      N 1 Reply Last reply
      0
      • N Neeraj Arora

        Hi All, I've a image gallery website where members can upload and restrict the access to few friends. The problem is, images are directly accessible from browser. How could I restrict specific folder to accessible from aspx pages only. Regards, Neeraj

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        Neeraj Arora wrote:

        How could I restrict specific folder to accessible from aspx pages only

        Write a http handler which handles requests for images. Check the authentication and display necessary messages. Make sure you map the extensions to ASP.NET in IIS settings.

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

        N 1 Reply Last reply
        0
        • N N a v a n e e t h

          Neeraj Arora wrote:

          How could I restrict specific folder to accessible from aspx pages only

          Write a http handler which handles requests for images. Check the authentication and display necessary messages. Make sure you map the extensions to ASP.NET in IIS settings.

          All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

          N Offline
          N Offline
          Neeraj Arora
          wrote on last edited by
          #4

          Thanks for reply but I'm not aware how to write this type of handler. Could you help me for a sample. Rgds, Neeraj

          N 1 Reply Last reply
          0
          • A Abhishek Sur

            I have done similar to this.. I have used a webservice to get the path of the requested images from an encrypted session guid which is created during login...

            Abhishek Sur

            N Offline
            N Offline
            Neeraj Arora
            wrote on last edited by
            #5

            Thanks for the reply. When I show image, anybody can check the relative path from viewsource and try other photos from same folder. Please correct me if I'm wrong or I understood your reply wrongly. Rgds, Neeraj

            1 Reply Last reply
            0
            • N Neeraj Arora

              Hi All, I've a image gallery website where members can upload and restrict the access to few friends. The problem is, images are directly accessible from browser. How could I restrict specific folder to accessible from aspx pages only. Regards, Neeraj

              N Offline
              N Offline
              NeverHeardOfMe
              wrote on last edited by
              #6

              There are two ways of doing this - an easy "hack" and a "proper" way... The easy way is simply to save your images with randomly assigned (GUID-type thing) filenames which can't be guessed. This doesn't stop people linking directly to your images once they know the filename of course, but unless your images are highly popular that is unlikely to be a problem, but it will stop them from finding images until you reveal the address. The proper way is to write a custom handler; you can find an example here[^]. Note though that depending on your version of IIS you may need to perform some steps differently - that article assumes IIS6; once you get above this you need to write your config file differntly, for one thing...

              1 Reply Last reply
              0
              • N Neeraj Arora

                Thanks for reply but I'm not aware how to write this type of handler. Could you help me for a sample. Rgds, Neeraj

                N Offline
                N Offline
                N a v a n e e t h
                wrote on last edited by
                #7

                here[^] you go

                All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

                N 1 Reply Last reply
                0
                • N N a v a n e e t h

                  here[^] you go

                  All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

                  N Offline
                  N Offline
                  Neeraj Arora
                  wrote on last edited by
                  #8

                  Thanks buddy.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups