469,927 Members | 1,235 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

HttpHandler question :: Retrieve the Request Page URL?

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
Nov 19 '05 #1
6 5405
Hi David,

Try HttpRequest.Path. This will give the virtual path of the current request..

Check this link..
http://msdn.microsoft.com/library/de...sPathTopic.asp

Do post a msg back in case this dosent help...

Happy Coding

"David Bowey" wrote:
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

Nov 19 '05 #2
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

"Vishnu-Chivukula" <Vi*************@discussions.microsoft.com> wrote in
message news:32**********************************@microsof t.com...
Hi David,

Try HttpRequest.Path. This will give the virtual path of the current
request..

Check this link...
http://msdn.microsoft.com/library/de...sPathTopic.asp

Do post a msg back in case this dosent help...

Happy Coding

"David Bowey" wrote:
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

Nov 19 '05 #3

"David Bowey" <db@f.coz> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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

Nov 19 '05 #4
>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
------------------------------------------------------------

"Vishnu-Chivukula" <Vi*************@discussions.microsoft.com> wrote in
message news:32**********************************@microsof t.com...
Hi David,

Try HttpRequest.Path. This will give the virtual path of the current
request..

Check this link...
http://msdn.microsoft.com/library/de...sPathTopic.asp

Do post a msg back in case this dosent help...

Happy Coding

"David Bowey" wrote:
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

Nov 19 '05 #5
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.

--
Matt Berther
http://www.mattberther.com
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


Nov 19 '05 #6
Hi Dave,

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

HTH,

Michel
"David Bowey" <db@f.coz> wrote in message news:<#3**************@TK2MSFTNGP14.phx.gbl>...
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

Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jed | last post: by
8 posts views Thread by bryan | last post: by
6 posts views Thread by Mike | last post: by
5 posts views Thread by Author | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.