Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Using global.asax to protect images? (http://www.velocityreviews.com/forums/t294940-using-global-asax-to-protect-images.html)

Bill 05-24-2006 09:34 PM

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.



Kevin Spencer 05-25-2006 11:19 AM

Re: Using global.asax to protect images?
 
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" <Bill541@yahoo.com> wrote in message
news:OMWYLo3fGHA.356@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.
>
>




vMike 05-25-2006 01:14 PM

Re: Using global.asax to protect images?
 

"Bill" <Bill541@yahoo.com> wrote in message
news:OMWYLo3fGHA.356@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.



Bill 05-25-2006 06:03 PM

Re: Using global.asax to protect images?
 
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.
> >
> >

>
>




Kevin Spencer 05-26-2006 02:35 PM

Re: Using global.asax to protect images?
 
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" <Bill541@yahoo.com> wrote in message
news:ObKgvWCgGHA.3364@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.
>> >
>> >

>>
>>

>
>




Bill 05-27-2006 07:35 PM

Re: Using global.asax to protect images?
 
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" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
news:eoXipGNgGHA.3900@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" <Bill541@yahoo.com> wrote in message
> news:ObKgvWCgGHA.3364@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.
> >> >
> >> >
> >>
> >>

> >
> >

>
>




Edwin Knoppert 05-27-2006 07:57 PM

Re: Using global.asax to protect images?
 
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" <Bill541@yahoo.com> schreef in bericht
news:OghBnTcgGHA.3588@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" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
> news:eoXipGNgGHA.3900@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" <Bill541@yahoo.com> wrote in message
>> news:ObKgvWCgGHA.3364@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.
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >

>>
>>

>
>




Kevin Spencer 05-28-2006 07:10 AM

Re: Using global.asax to protect images?
 
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" <Bill541@yahoo.com> wrote in message
news:OghBnTcgGHA.3588@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" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
> news:eoXipGNgGHA.3900@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" <Bill541@yahoo.com> wrote in message
>> news:ObKgvWCgGHA.3364@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.
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >

>>
>>

>
>




Bill 05-31-2006 06:19 PM

Re: Using global.asax to protect images?
 
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.
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>

> >
> >

>
>





All times are GMT. The time now is 06:54 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.