473,847 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 5597
Hi David,

Try HttpRequest.Pat h. 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.AbsoluteUr i

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.m icrosoft.com> wrote in
message news:32******** *************** ***********@mic rosoft.com...
Hi David,

Try HttpRequest.Pat h. 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.AbsoluteUr i

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******** ********@TK2MSF TNGP14.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.AbsoluteUr i

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.m icrosoft.com> wrote in
message news:32******** *************** ***********@mic rosoft.com...
Hi David,

Try HttpRequest.Pat h. 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.AbsoluteUr i

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

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.Pa thAndQuery, for instance.

HTH,

Michel
"David Bowey" <db@f.coz> wrote in message news:<#3******* *******@TK2MSFT NGP14.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.AbsoluteUr i

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2874
by: Earl Teigrob | last post by:
My company sells software and wants to provide downloadable product. Some of these downloads will be full CD's of over 550M I had everything working fine using Response.filewrite() but when we tested it with large files, it blew up. (crashed the server, well documented problem) I can download a file just fine if I just point to the download file and let IIS generate the download dialog (but with no security, of course)
3
7983
by: Jed | last post by:
I have written an HttpHandler which I invoke through an ashx page. The HttpHandler does various things to process the request, then it is supposed to redirect to a confirmation page. Everything up to the redirect works fine, but I can't get the redirect to work. If I do a ... context.Response.Write("Hello World"); .... the HttpHandler works great and the browser loads the text fine, but if I change it to ...
2
2153
by: rpale | last post by:
We want to create server-side code that will retrieve the user requested pages, then manipulate the content of those pages just before being sent back to the user. We tried the following: • User requests the page, call it http://www.test.com/testapp/test.aspx • IIS receives the request • HttpHandler is called for all .aspx files requested as defined in the web.config file for this application <httpHandlers> <add verb="*"...
0
1410
by: Anonieko | last post by:
Jefrey Palermo How to do Url Rewriting with just an HttpHandler (without the side-effects) - level 400 posted on Wednesday, August 10, 2005 7:21 PM If you are interested in doing Url Rewriting with an HttpHandler instead of an HttpModule, then this is the example for you. Suppose you are deriving a piece of information from Url, like a product code. To process it, you have a page that accepts the product code as a querystring...
8
3915
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really need to avoid the extra round-trip to the client. I've tried Passing the page name, the full URL, and the instance of the handler class to the Transfer method, but everything gets me the same error 500. Any help would be appreciated.
6
3363
by: Mike | last post by:
Hi, I have a problem of page redirection. Basically, the user has to connect to the local web server, but some pages need to be served by a remote server, because it contains some confidential data that cannot be moved locally (everything occurs in the company Intranet, however). Since the ASP.NET application uses extensive Javascript, we cannot make it work because of the "cross-site" (same origin policy) of Javascript. Therefore, we...
5
4335
by: zlf | last post by:
Hello, I try to use a custom HttpHandler to add something to session, then display the original page. public void ProcessRequest(HttpContext context) { context.Session = "test"; } But, a empty page is rendered with this HttpHandler, should I add some
2
1541
by: wickedHangover | last post by:
I'm writing some code to act as a proof of concept which at this point works ok, there is a minor issue I would like to resolve. What I have is an image database being served in an academic library setting with some pretty tight copyright restrictions. Until now we have simply restricted the images to on-campus use, so you can either VPN/Proxy to the network or use a machine physically on the network to access the image collection. Before...
5
7317
by: Author | last post by:
I followed the example at http://support.microsoft.com/kb/308001/EN-US/ and created my own HttpHandler. Here is the code: using System.Web; namespace MyNameSpace { public class SyncHttpHandler: IHttpHandler
0
9892
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9734
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10718
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10347
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7888
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5725
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4129
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3168
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.