0

I want know which page and which URL has calling my Handler .ashx, is that possible?

I need this because, I have an Handler who calls and convert images from database, but some of my URLS of images are not passing the right query argument (they don't exist in database) and I need what is the URL who call to see what is the image for that arguments.

oteal
  • 614
  • 2
  • 13
  • 25

2 Answers2

3

why not just use context.Request.UrlReferrer?

tichra
  • 557
  • 5
  • 18
0

A quick solution to your immediate question is to call (in C#)

Inside your public void ProcessRequest(HttpContext context){} method, add the following 3 lines.

       IServiceProvider provider = (IServiceProvider)context;
       HttpWorkerRequest worker = (HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest));
       String referer = worker.GetKnownRequestHeader(HttpWorkerRequest.HeaderReferer);

This will give you the URL of the page that called your handler.

To go further though, you should ideally be implementing error handling to handle any missing images.

Darren Wainwright
  • 30,247
  • 21
  • 76
  • 127