asp.net - How can i hide/secure image path? -


how can hide/secure image path in asp.net? don't want user see image path directly.

i have googled problem , found following url:

http://www.codeproject.com/kb/web-security/imageobfuscation.aspx

on page suggests changing image path this:

<img id='imagecontrol'         src='showimage.axd?path=<% encryptstring("c:\images\img.ext", page) %>'  

but if user copy image src , paste browser domain name show image.

it depends on trying achieve.

if you're trying stop people linking images site, best option extend handler mentioned in question return image if request.referrer own site.

this means if did try , link image via handler, they'd see broken image/no image, wouldn't able request image directly in browsers, etc.

you should include sort of time stamp in encrypted path, , reject requests come long ago - again limit validity of links:

<img id='imagecontrol'       src='showimage.axd?path=<% encryptstring("c:\images\img.ext|" + datetime.now.tostring(), page) %>'  

then in handler:

dim pathandtimeenc string = ctx.request.params("path") dim pathandtime string dim path string dim timestamp datetime  pathandtime = common.decryptstring(pathandtimeenc, ctx) dim parts = pathandtime.split("|"c) path = parts(0) timestamp = datetime.parse(parts(1))  dim fivemin timespan = new timestamp(0, 5, 0) if datetime.now.subtract(timestamp) < fivemin   ' return image. end if 

if you're trying stop people downloading images you're not going stop more basic internet user - after display image on site, you'll need send copy of client browser.

however, couple of possible options make harder:

  1. ensure images expire immediately, means browser shouldn't keep them locally long - mean none of images cached, , you'll end higher bandwidth useage repeat viewers; if using handler can in code: response.cache.setcacheability(httpcacheability.nocache); response.cache.setexpires(datetime.now);
  2. use css place transparent 1x1px image on top of images on site - way if user right-clicks on image save it, path transparent image rather 1 expecting (flickr does/used this)

at end of day, if put content online, it's hard stop dedicated "thief" taking , using it.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -