Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3396414
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:24:17+00:00 2026-05-18T04:24:17+00:00

How can I hide/secure image path in asp.net? I don’t want the user see

  • 0

How can I hide/secure image path in asp.net? I don’t want the user see image path directly.

I have googled with my problem and found the following URL:

http://www.codeproject.com/KB/web-security/ImageObfuscation.aspx

On this page it suggests changing the image path like this:

<img ID='ImageControl'   
     src='ShowImage.axd?Path=<% EncryptString("C:\Images\img.ext", Page) %>' 

But if user copy this image src and paste it into their browser with the domain name then it will show image.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:24:18+00:00Added an answer on May 18, 2026 at 4:24 am

    It really depends on what you are trying to achieve.

    If you’re trying to stop people linking to your images from another site, then the best option would be to extend the handler you mentioned in your question to only return an image if the Request.Referrer is your own site.

    This means that if they did then try and link to the image via your handler, they’d only see a broken image/no image, they wouldn’t be able to request the image directly in their browsers, etc.

    You should also probably include some sort of time stamp in the encrypted path, and reject requests that come from too long ago – this will again limit the validity of the links:

    <img ID='ImageControl' 
         src='ShowImage.axd?Path=<% EncryptString("C:\Images\img.ext|" + DateTime.Now.ToString(), Page) %>' 
    

    Then in your handler:

    Dim pathAndTimeEnc As String = ctx.Request.Params("Path")
    Dim pathAndTime As String
    Dim path As String
    Dim timeStamp As DateTime
    
    pathAndTime = Common.DecryptString(pathAndTimeEnc, ctx)
    Dim parts = pathAndTime.Split("|"C)
    path = parts(0)
    timeStamp = DateTime.Parse(parts(1))
    
    Dim fiveMin As TimeSpan = New TimeStamp(0, 5, 0)
    If DateTime.Now.Subtract(timeStamp) < fiveMin Then
      ' Return image.
    End If
    

    If you’re trying to stop people downloading your images then you’re not really going to stop more than the most basic internet user – after all to display the image on your site, you’ll need to send a copy of it to the client browser.

    However, a couple of possible options to make it harder:

    1. Ensure that the images expire immediately, this means the browser shouldn’t keep them locally for that long – however it does mean that none of the images will be cached, and you’ll end up with higher bandwidth useage for repeat viewers; if you are using the handler you can do this in code:
      Response.Cache.SetCacheability(HttpCacheability.NoCache);
      Response.Cache.SetExpires(DateTime.Now);
    2. Use CSS to place a transparent 1x1px image over the top of the images on your site – this way if a user right-clicks on the image to save it, they will get the path to the transparent image rather than the one they are expecting (Flickr does/used to do this)

    At the end of the day, if you put some content online, then it’s very hard to stop the most dedicated “thief” from taking it and using it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a secure website using ASP.NET, but when I publish it,
can anyone tell me how i can hide the real name of a asp.net
I have a list of li tags and I can hide and show no
Does anyone have any info or code on how to can hide a navigation
Is there any way we can hide column of display table,we have media=none which
I have html where I only want to hide the text portion, but what
I want to hide the frontmost app. I know you can hide a process
When using a standard .NET Xml Serializer, is there any way I can hide
I want to develop a program that can hide a folder. Not a hidden
I have javascript which can hide empty fields from sharepoint display form. http://sharepointjavascript.wordpress.com/2009/10/15/hide-empty-rows-in-dispform/ I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.