1

Simple question:

How to know if some request/call goes from localhost in the code below?

Is it possible in fact?

Thanks!!

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
public class Service2 : IService2
{
        public void DoWork()
        {
           // Is this the localhost ?
        }
}
NoWar
  • 36,338
  • 80
  • 323
  • 498

1 Answers1

1

you can find the ip address of request coming computer by using

HttpContext.Current.Request.UserHostAddress

or there are few other alternatives as well (Obtaining client IP address in WCF 3.0)

based on ip address you can decide request/call goes from localhost or not.

If you need to debug web service you can run client and service at ones and put break point on service method.

Community
  • 1
  • 1
Damith
  • 62,401
  • 13
  • 102
  • 153