HttpHandler: context.Request.UrlReferrer data is null

  • Thread starter deepak.bhardwaj
  • Start date
D

deepak.bhardwaj

Hi,

I have implemented the IHttpHandler interface for generating images and
writing them to response stream in binary format. I use an
IHttpHandlerFactory to instantiate that handler. A .aspx page sends a
request to the factory which then instantiates an instance of the
handler. The response is read by a third party component that then
displays the image.

i.e. inside .aspx page:
-------------------------
3rdPartyComp.ImageURL =
"http:\\localhost\ImageGenerator\image.imgr?x=100&y=200";

(.imgr extension is registered with IIS and is declared in web.config
httphandler section)

While debugging this handler, I came across a weird situation where the
context parameter that gets passed in ProcesRequest module has null
value for the context.Request.UrlReferrer parameter. Other stuff like
querystring, sessionstate (implemented IRequiresSessionState in
handler) etc. do exist though. Needless to say..the HttpInputStream is
empty when I tried to view its contents.

I used 'Fiddler' to track requests sent to the handler but that did not
help much.

Would appreciate if anyone who faced the same issue could help me
identify the missing link.

Thanks
 
J

John Saunders

Hi,

I have implemented the IHttpHandler interface for generating images and
writing them to response stream in binary format. I use an
IHttpHandlerFactory to instantiate that handler. A .aspx page sends a
request to the factory which then instantiates an instance of the
handler. The response is read by a third party component that then
displays the image.

i.e. inside .aspx page:
-------------------------
3rdPartyComp.ImageURL =
"http:\\localhost\ImageGenerator\image.imgr?x=100&y=200";

(.imgr extension is registered with IIS and is declared in web.config
httphandler section)

While debugging this handler, I came across a weird situation where the
context parameter that gets passed in ProcesRequest module has null
value for the context.Request.UrlReferrer parameter. Other stuff like
querystring, sessionstate (implemented IRequiresSessionState in
handler) etc. do exist though. Needless to say..the HttpInputStream is
empty when I tried to view its contents.

I used 'Fiddler' to track requests sent to the handler but that did not
help much.

Would appreciate if anyone who faced the same issue could help me
identify the missing link.

There may not be a missing link. The UrlReferrer comes from an Http header.
If the header is not provided, then UrlReferrer will be null.

This is an expected situation.

John
 
G

Guest

Thanks for replying John. Regarding header info, 'Fiddler' showed me that a
header is being sent but does not have all info. ASP.NET tracing reconfirmed
this behavior.

However, I recently discovered that if I have an image tag whose src
attribute is set to the image httphandler, everything works fine and context
is not null. It still doesn't work otherwise. So I am still stuck :(

Thanks
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top