Using global.asax to protect images?

B

Bill

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.
 
K

Kevin Spencer

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.
 
V

vMike

Bill said:
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.
 
B

Bill

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.


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.

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.
 
K

Kevin Spencer

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 said:
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.


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.

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.
 
B

Bill

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 said:
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 said:
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.


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.

...
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.
 
E

Edwin Knoppert

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 said:
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 said:
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 said:
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.


..
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.

...
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.
 
K

Kevin Spencer

Hi Bill,

Here's a good one:

http://geekswithblogs.net/flanakin/articles/HttpHandlers.aspx

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

This is, by definition, not that.

Bill said:
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 said:
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 said:
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.


..
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.

...
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.
 
B

Bill

Excellent, thanks Kevin!

Bill.


Hi Bill,

Here's a good one:

http://geekswithblogs.net/flanakin/articles/HttpHandlers.aspx

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

This is, by definition, not that.

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.


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.

...
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.


..
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.

...
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top