oteal
oteal

Reputation: 634

Which Page is calling the Handler ashx

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.

Upvotes: 0

Views: 1127

Answers (2)

tichra
tichra

Reputation: 553

why not just use context.Request.UrlReferrer?

Upvotes: 3

Darren Wainwright
Darren Wainwright

Reputation: 30737

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.

Upvotes: 0

Related Questions