views:

29

answers:

2

How can I tell from within an ASP.NET HttpHandler if it is executing because of a call to

Server.Execute("myHandler.ashx")

or because of the user linking directly to myHandler.ashx? (Besides using a querystring parameter).

+1  A: 

Can't you add a querystring parameter? If present comes from Server.Execute(), otherwise direct link.

Claudio Redi
Yes, this is what I'm doing right now. I'm wondering if there is something else I can get from the HttpContext that will tell me.
Chris Dwyer
A: 

You should still have access to the HttpContext from within the handler, so you should still be able to access cookies and session to determine any authenticated users (if that's what you're looking for).

Joel Etherton
In both cases the user will be authenticated on the site.
Chris Dwyer
@Chris Dwyer - right, so you should have access to all of that information from within the handler.
Joel Etherton
@Joel - what should I check in the Request that would tell me what I need to know?
Chris Dwyer
@Chris Dwyer - If you're using formsauthentication with cookies, you could use HttpContext.Current.Request.Cookies["YourCookieName"] to grab their cookie data and unencrypt/read their FormsauthenticationTicket.
Joel Etherton