views:

817

answers:

3

Hey all,

I am creating an HTTP handler that listens for calls to a specific file type, and handles it accordingly. My HTTP Handler listens for .bcn files, then writes a cookie to the user's computer and sends back an image... this will be used in advertising banners so that the user is tagged as seeing the banner, and we can then offer special deals when they visit our site later.

The problem i'm having is getting access to the Page object... of course an HTTPHandler is not actually a page, and since the Response object lives within the Page object, I can't get access to it to write the cookie.

Is there a way around this, or do i need to revert back to just using a standard aspx page to do this?

Thanks heaps.. Greg

A: 

You can access the Response object from the HttpContext object passed to the ProcessRequest method from IHttpHandler. This is the same object exposed by Page.Response.

ckramer
A: 

the ProcessRequest() method defined in IHttpHandler is passed a HttpContext reference. This HttpContext object will have a property named Response and Request, which you can use.

cruizer
A: 

ah yes... thanks heaps cKramer :)

Working code is:

HttpContext.Current.Response.Cookies.Add(cookie);
Gregorius