I am working on some error handling code and I want to determine if its a local connection (developer) or not. Typically I look at HttpContext.Current.Request.ServerVariables however in the error handling code if authentication expired HttpContext.Current is null.

When HttpContext.Current is null, how do I go about getting the server variables--or at least the IP address of the client that kicked off the request--so I can determine if its a developer on their own local server or not.

UPDATE: I was able to retrieve the relevant server variables in the ErrorMailEventArgs parameter passed in by elmah, specifically errorMailEventArgs.Error.ServerVariables.

3

There are 3 best solutions below

5
On BEST ANSWER

I was able to retrieve the relevant server variables in the ErrorMailEventArgs parameter passed in by elmah, specifically errorMailEventArgs.Error.ServerVariables.

0
On

The Request object should get you the requesting IP.

2
On

The request object has these properties:

Request.UserHostAddress

MSDN Link