views:

49

answers:

3

How can you programmatically determine if an an ASP.NET request is remote or from the localhost?

A: 

You can check the Request.UserHostAddress property.

Dean Harding
Which can be spoofed. And not reliable if the host has multiple nics.
Oded
It can't be spoofed. It's no less reliable than Request.IsLocal (in fact, if you look in Reflector, IsLocal is implemented in terms of UserHostAddress!)
Dean Harding
+6  A: 

I found it: HttpContext.Current.Request.IsLocal

Ronnie Overby
A: 

yes HttpContext.Current.Request.IsLocal will must works. I am also using it in one of my project and working fine.

Harendra