HttpHandler question :: Retrieve the Request Page URL?

D

David Bowey

Hi There!

I'm writing a custom HttpHandler to create watermarks on my PNG images of my
website. So typically, a PNG image is linked in an ASPX page as follows...

<img src="images/test.png" alt="testing" />

So I created an HttpHanlder to handle PNG images, have mapped the PNG
extension in the IIS and also added the HttpModule section in the web.config
file.

In my HttpHandler's ProcessRequest event, I tried to retireve the Page URL
by...

context.Request.Url.AbsoluteUri

But it is not returning the Page's URL but returning the URL of the PNG
image.

How can I retrieve the URL of the PAGE that links the PNG image?

Thank you all in advance!!!
Dave
 
D

David Bowey

Hi Vishnu,

Thanks for the help! But it didn't work out. I tried with the following
code...

context.Request.Path

It is still giving me the path of the PNG image and not the ASPX file path.

Any ideas?

Thanks again!
Dave
 
D

David Bowey

David Bowey said:
Hi There!

I'm writing a custom HttpHandler to create watermarks on my PNG images of
my website. So typically, a PNG image is linked in an ASPX page as
follows...

<img src="images/test.png" alt="testing" />

So I created an HttpHanlder to handle PNG images, have mapped the PNG
extension in the IIS and also added the HttpModule section in the
web.config file.

In my HttpHandler's ProcessRequest event, I tried to retireve the Page URL
by...

context.Request.Url.AbsoluteUri

But it is not returning the Page's URL but returning the URL of the PNG
image.

How can I retrieve the URL of the PAGE that links the PNG image?

Thank you all in advance!!!
Dave
 
A

Alvin Bruney [ASP.NET MVP]

added the HttpModule section in the web.config
typo??? You should be mapping the HttpHandler section in the web.config
since you wrote a handler and not a module.

--
Regards,
Alvin Bruney

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
------------------------------------------------------------
 
M

Matt Berther

Hello David,

You can not make this happen using the builtin objects, because as far as
the web server is concerned this is two completely separate requests, completely
independent of each other.

However, you could try passing the page name along as a parameter on the
query string. If you do that, make sure you test it for null though, because
if an image is direct-linked without the page name, you'll throw an exception
if you try and do anything with it.
 
F

fd123456

Hi Dave,

I haven't tried, but the referrer should be what you're looking for :
Context.Request.UrlReferrer.PathAndQuery, for instance.

HTH,

Michel
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top