locked
How to Prevent virtual directory access in browser RRS feed

  • Question

  • User1672837937 posted

    Hi All,

    I want to prevent virtual directory access to directly in browser. i have image, PDF etc in my virtual directory to access from website. 

    Example:

    i want to restrict from browser https://mywebsite/virtual directory name/image.jpg and should allow the image in page like <image src="https://mywebsite/virtual directory name/iamge.jpg"/>

    i used 

    <hiddenSegments>
    <add segment="virtual directory name" />
    </hiddenSegments>

    but it is restrict both inside website and browser. Please help us how can i implement this functionality.

    Thanks in Advance,

    Dhamu

    Thursday, June 28, 2018 5:50 AM

All replies

  • User409696431 posted

    The browser needs access to your image link in order to display it.  You can't have it both ways.  I'll mention that when you link to an image in the page, the visitor already has a downloaded copy of that image in their browser cache, so there is no additional security achieved by trying to block direct access to the image.

    … So, what is your goal?  That would help with suggestions, if any.  For example, if you are trying to protect images from being downloaded, you could base64 encode all the images used in your site, and not link to them.  It's a bit of a hassle, and generates quite a lot of page markup for large/complex images.

    Thursday, June 28, 2018 6:20 AM
  • User1672837937 posted

    Hi Kathy,

    In my virtual directory contains not only image. i have files also like pdf, xls etc.. you think it is not possible to achieve both ways using link?.

    Please let us know is there any other way?

    Thanks in Advance,

    Dhamu 

    Thursday, June 28, 2018 6:33 AM
  • User409696431 posted

    I don't know any other way.   What is the issue you are trying to solve, since visitors to your site can see those documents on your pages, anyway, presumably.

    Thursday, June 28, 2018 6:39 AM