开发者

How do I (in ASP.NET) determine if the connection is a remote connection?

开发者 https://www.devze.com 2022-12-20 02:06 出处:网络
I\'m trying to implement a bit of functionality that will behave much like the CustomError pages: if the connection is re开发者_如何学运维mote function A() will run; else function B() will run.

I'm trying to implement a bit of functionality that will behave much like the CustomError pages: if the connection is re开发者_如何学运维mote function A() will run; else function B() will run.

The only problem I'm having is that I'm not sure the best way to determine a "remote" connection. Does it matter if I'm running my code on a shared web host? Can I rely on just comparing "my" IP to the request's IP?


That's easy in ASP.NET - just check HttpContext.Current.Request.IsLocal. It will be true when the request was made from the local computer, and false for a remote computer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号