473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Using global.asax to protect images?

Anyone have any success in using global.asax to protect images in a folder from being
linked to by external websites?

I'd tried to use global.asa in the past, with no success. Any help would be appreciated.

THANKS,

Bill.
May 24 '06 #1
8 1897
I don't believe this can be done in the global.asax. I'm not sure that this
is the only way to accomplish this, but at least one method would be to
create a custom HttpHandler for all image requests. When an image is
requested the HttpHandler can look at the
Request.Servervariables["HTTP_REFERER"] to ascertain that the request is
being referred from a page in the web itself, and redirect or take
appropriate action to not deliver the image if the HttpReferer is not in the
web's domain.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

If the truth hurts, wear it.

"Bill" <Bi*****@yahoo.com> wrote in message
news:OM*************@TK2MSFTNGP02.phx.gbl...
Anyone have any success in using global.asax to protect images in a folder
from being
linked to by external websites?

I'd tried to use global.asa in the past, with no success. Any help would
be appreciated.

THANKS,

Bill.

May 25 '06 #2

"Bill" <Bi*****@yahoo.com> wrote in message
news:OM*************@TK2MSFTNGP02.phx.gbl...
Anyone have any success in using global.asax to protect images in a folder from being linked to by external websites?

I'd tried to use global.asa in the past, with no success. Any help would be appreciated.
THANKS,

Bill.


Another idea that I have used with reasonable success is to have the image
url set to .aspx file and have the .aspx save the image to the
Response.OutputStream. You can exercise quite a bit of control over what
gets streamed depending on referrer conditions or cookie conditions. You can
also resize images on the fly, add text, etc (using system.drawing.image).
It doesn't stop someone from right clicking and saving the image, but it
does stop bots from getting the images. It does add some processing time so
I only do it for high quality images and if a bot come through, I just give
them a thumbnail.

Mike
Hope this helps.
May 25 '06 #3
Hi, Kevin:

Yea, I looked into using a custom HttpHandler in my web.config. However, all the
examples I've seen require creating a .DLL, and although I own a copy of Visual Basic 6,
creating .DLLs is outside of my area of expertise.

Unless... is there a way for HttpHandler to be associated with a .aspx page instead?

Thanks,

Bill.
"Kevin Spencer" wrote..
I don't believe this can be done in the global.asax. I'm not sure that this
is the only way to accomplish this, but at least one method would be to
create a custom HttpHandler for all image requests. When an image is
requested the HttpHandler can look at the
Request.Servervariables["HTTP_REFERER"] to ascertain that the request is
being referred from a page in the web itself, and redirect or take
appropriate action to not deliver the image if the HttpReferer is not in the
web's domain.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

If the truth hurts, wear it.

"Bill" wrote...
Anyone have any success in using global.asax to protect images in a folder
from being
linked to by external websites?

I'd tried to use global.asa in the past, with no success. Any help would
be appreciated.

THANKS,

Bill.


May 25 '06 #4
Hi Bill,

Just because you can't compile a DLL doesn't mean you can't use a class. If
you're using ASP.Net 2.0, you can create a .cs (or .vb) file with a class
definition in it and deploy it to your /app_code directory.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

This is, by definition, not that.

"Bill" <Bi*****@yahoo.com> wrote in message
news:Ob**************@TK2MSFTNGP05.phx.gbl...
Hi, Kevin:

Yea, I looked into using a custom HttpHandler in my web.config. However,
all the
examples I've seen require creating a .DLL, and although I own a copy of
Visual Basic 6,
creating .DLLs is outside of my area of expertise.

Unless... is there a way for HttpHandler to be associated with a .aspx
page instead?

Thanks,

Bill.
"Kevin Spencer" wrote..
I don't believe this can be done in the global.asax. I'm not sure that
this
is the only way to accomplish this, but at least one method would be to
create a custom HttpHandler for all image requests. When an image is
requested the HttpHandler can look at the
Request.Servervariables["HTTP_REFERER"] to ascertain that the request is
being referred from a page in the web itself, and redirect or take
appropriate action to not deliver the image if the HttpReferer is not in
the
web's domain.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

If the truth hurts, wear it.

"Bill" wrote...
> Anyone have any success in using global.asax to protect images in a
> folder
> from being
> linked to by external websites?
>
> I'd tried to use global.asa in the past, with no success. Any help
> would
> be appreciated.
>
> THANKS,
>
> Bill.
>
>



May 26 '06 #5
Kevin, although I rock in Classic ASP, I'm new to ASP.NET. I'm a quick study on ASP.NET,
but I've never done a class before.

Could you point me to a beginner reference so that I can teach myself what you are
recommending?

Thanks!

Bill.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eo**************@TK2MSFTNGP05.phx.gbl...
Hi Bill,

Just because you can't compile a DLL doesn't mean you can't use a class. If
you're using ASP.Net 2.0, you can create a .cs (or .vb) file with a class
definition in it and deploy it to your /app_code directory.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

This is, by definition, not that.

"Bill" <Bi*****@yahoo.com> wrote in message
news:Ob**************@TK2MSFTNGP05.phx.gbl...
Hi, Kevin:

Yea, I looked into using a custom HttpHandler in my web.config. However,
all the
examples I've seen require creating a .DLL, and although I own a copy of
Visual Basic 6,
creating .DLLs is outside of my area of expertise.

Unless... is there a way for HttpHandler to be associated with a .aspx
page instead?

Thanks,

Bill.
"Kevin Spencer" wrote..
I don't believe this can be done in the global.asax. I'm not sure that
this
is the only way to accomplish this, but at least one method would be to
create a custom HttpHandler for all image requests. When an image is
requested the HttpHandler can look at the
Request.Servervariables["HTTP_REFERER"] to ascertain that the request is
being referred from a page in the web itself, and redirect or take
appropriate action to not deliver the image if the HttpReferer is not in
the
web's domain.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

If the truth hurts, wear it.

"Bill" wrote...
> Anyone have any success in using global.asax to protect images in a
> folder
> from being
> linked to by external websites?
>
> I'd tried to use global.asa in the past, with no success. Any help
> would
> be appreciated.
>
> THANKS,
>
> Bill.
>
>



May 27 '06 #6
Wonder why you choose for global.asax ?
If the image is obtained through a generic handler (and simply streamed),
you could decide to set a tag in it's session to allow the user.
Afaik this should be possible.

Even so, the generic handler can be called with parameters, these could be
temporary.


"Bill" <Bi*****@yahoo.com> schreef in bericht
news:Og**************@TK2MSFTNGP04.phx.gbl...
Kevin, although I rock in Classic ASP, I'm new to ASP.NET. I'm a quick
study on ASP.NET,
but I've never done a class before.

Could you point me to a beginner reference so that I can teach myself what
you are
recommending?

Thanks!

Bill.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eo**************@TK2MSFTNGP05.phx.gbl...
Hi Bill,

Just because you can't compile a DLL doesn't mean you can't use a class.
If
you're using ASP.Net 2.0, you can create a .cs (or .vb) file with a class
definition in it and deploy it to your /app_code directory.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

This is, by definition, not that.

"Bill" <Bi*****@yahoo.com> wrote in message
news:Ob**************@TK2MSFTNGP05.phx.gbl...
> Hi, Kevin:
>
> Yea, I looked into using a custom HttpHandler in my web.config.
> However,
> all the
> examples I've seen require creating a .DLL, and although I own a copy
> of
> Visual Basic 6,
> creating .DLLs is outside of my area of expertise.
>
> Unless... is there a way for HttpHandler to be associated with a .aspx
> page instead?
>
> Thanks,
>
> Bill.
>
>
> "Kevin Spencer" wrote..
>> I don't believe this can be done in the global.asax. I'm not sure that
>> this
>> is the only way to accomplish this, but at least one method would be
>> to
>> create a custom HttpHandler for all image requests. When an image is
>> requested the HttpHandler can look at the
>> Request.Servervariables["HTTP_REFERER"] to ascertain that the request
>> is
>> being referred from a page in the web itself, and redirect or take
>> appropriate action to not deliver the image if the HttpReferer is not
>> in
>> the
>> web's domain.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Numbskull
>>
>> If the truth hurts, wear it.
>>
>> "Bill" wrote...
>> > Anyone have any success in using global.asax to protect images in a
>> > folder
>> > from being
>> > linked to by external websites?
>> >
>> > I'd tried to use global.asa in the past, with no success. Any help
>> > would
>> > be appreciated.
>> >
>> > THANKS,
>> >
>> > Bill.
>> >
>> >
>>
>>
>
>



May 27 '06 #7
Hi Bill,

Here's a good one:

http://geekswithblogs.net/flanakin/a...pHandlers.aspx

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

This is, by definition, not that.

"Bill" <Bi*****@yahoo.com> wrote in message
news:Og**************@TK2MSFTNGP04.phx.gbl...
Kevin, although I rock in Classic ASP, I'm new to ASP.NET. I'm a quick
study on ASP.NET,
but I've never done a class before.

Could you point me to a beginner reference so that I can teach myself what
you are
recommending?

Thanks!

Bill.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eo**************@TK2MSFTNGP05.phx.gbl...
Hi Bill,

Just because you can't compile a DLL doesn't mean you can't use a class.
If
you're using ASP.Net 2.0, you can create a .cs (or .vb) file with a class
definition in it and deploy it to your /app_code directory.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

This is, by definition, not that.

"Bill" <Bi*****@yahoo.com> wrote in message
news:Ob**************@TK2MSFTNGP05.phx.gbl...
> Hi, Kevin:
>
> Yea, I looked into using a custom HttpHandler in my web.config.
> However,
> all the
> examples I've seen require creating a .DLL, and although I own a copy
> of
> Visual Basic 6,
> creating .DLLs is outside of my area of expertise.
>
> Unless... is there a way for HttpHandler to be associated with a .aspx
> page instead?
>
> Thanks,
>
> Bill.
>
>
> "Kevin Spencer" wrote..
>> I don't believe this can be done in the global.asax. I'm not sure that
>> this
>> is the only way to accomplish this, but at least one method would be
>> to
>> create a custom HttpHandler for all image requests. When an image is
>> requested the HttpHandler can look at the
>> Request.Servervariables["HTTP_REFERER"] to ascertain that the request
>> is
>> being referred from a page in the web itself, and redirect or take
>> appropriate action to not deliver the image if the HttpReferer is not
>> in
>> the
>> web's domain.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Numbskull
>>
>> If the truth hurts, wear it.
>>
>> "Bill" wrote...
>> > Anyone have any success in using global.asax to protect images in a
>> > folder
>> > from being
>> > linked to by external websites?
>> >
>> > I'd tried to use global.asa in the past, with no success. Any help
>> > would
>> > be appreciated.
>> >
>> > THANKS,
>> >
>> > Bill.
>> >
>> >
>>
>>
>
>



May 28 '06 #8
Excellent, thanks Kevin!

Bill.
"Kevin Spencer" wrote...
Hi Bill,

Here's a good one:

http://geekswithblogs.net/flanakin/a...pHandlers.aspx

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

This is, by definition, not that.

"Bill" wrote...
Kevin, although I rock in Classic ASP, I'm new to ASP.NET. I'm a quick
study on ASP.NET,
but I've never done a class before.

Could you point me to a beginner reference so that I can teach myself what
you are
recommending?

Thanks!

Bill.
"Kevin Spencer" wrote...
Hi Bill,

Just because you can't compile a DLL doesn't mean you can't use a class.
If
you're using ASP.Net 2.0, you can create a .cs (or .vb) file with a class
definition in it and deploy it to your /app_code directory.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

This is, by definition, not that.

"Bill" wrote...
> Hi, Kevin:
>
> Yea, I looked into using a custom HttpHandler in my web.config.
> However,
> all the
> examples I've seen require creating a .DLL, and although I own a copy
> of
> Visual Basic 6,
> creating .DLLs is outside of my area of expertise.
>
> Unless... is there a way for HttpHandler to be associated with a .aspx
> page instead?
>
> Thanks,
>
> Bill.
>
>
> "Kevin Spencer" wrote..
>> I don't believe this can be done in the global.asax. I'm not sure that
>> this
>> is the only way to accomplish this, but at least one method would be
>> to
>> create a custom HttpHandler for all image requests. When an image is
>> requested the HttpHandler can look at the
>> Request.Servervariables["HTTP_REFERER"] to ascertain that the request
>> is
>> being referred from a page in the web itself, and redirect or take
>> appropriate action to not deliver the image if the HttpReferer is not
>> in
>> the
>> web's domain.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Numbskull
>>
>> If the truth hurts, wear it.
>>
>> "Bill" wrote...
>> > Anyone have any success in using global.asax to protect images in a
>> > folder
>> > from being
>> > linked to by external websites?
>> >
>> > I'd tried to use global.asa in the past, with no success. Any help
>> > would
>> > be appreciated.
>> >
>> > THANKS,
>> >
>> > Bill.
>> >
>> >
>>
>>
>
>



May 31 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Sedlak | last post by:
Hello, I am making a database driven website that allows the user to login and do some stuff all around my website. I was wondering what file I could use for global variables and functions. Or is...
12
by: Luther Hert | last post by:
While trying to work through textbook lessons for Vb.net Step by Step,Version 2003, Chapter 22, the first step is to create a new Web application Project,using the ASP.Net Application icon in the...
12
by: John M | last post by:
Hello, On Microsoft Visual Studio .NET 2003, I want to use some global elements, that can be used in each one of my pages. i.e I put a oleDBConnection on global.asax.vb How can I use it...
1
by: Anonieko | last post by:
Global.asax? Use HttpModules Instead! In a previous post, I talked about HttpHandlers - an underused but incredibly useful feature of ASP.NET. Today I want to talk about HttpModules, which are...
1
by: Anonieko | last post by:
Understanding and Using Exceptions (this is a really long post...only read it if you (a) don't know what try/catch is OR (b) actually write catch(Exception ex) or catch{ }) The first thing I...
4
by: Al Santino | last post by:
Hello, I've created a simple C# web services project using Visual Studio 2005. My service compiles and runs correctly when called by remote clients. I'm able to step through the service in the...
8
by: Victor | last post by:
Can I get the events in GLOBAL.ASAX to fire if a classic ASP page is being accessed by the user?
16
by: thefritz_j | last post by:
We just converted our VS2003 1.1 VB web project (which was working fine) to VS2005 2.0 and now I get: Parser Error Message: Could not load type '<Namespace>.'. Source Error: Line 1: <%@...
15
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax code file. In 1.1 I could have a code behind file for the global.asax file. This allow for shared variables of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.