Search code examples
c#asp.netrequestlanwan

Client connection information


I'm writing a program that is accessed from a local network and also from the outside. I have to identify local and outside requests in order to give different functionality to each. Is that possible? An alternative is to document the IP addresses of all the local computers and to get the IP address of the client thru Request.ServerVariables["Remote_ADDRS"] and compare them, if the request IP address doesn't match that means the request is not local. That seems to be awkward and inefficient because I would have to save all local addresses and any new computer would have to be regestered. Is there a simple way to identify if a request is coming from the local network or from the outside? Thank you!


Solution

  • Your network administrator will be able to tell you the IP range of the internal network. Then you can simply check if the client IP falls into the internal range.

    This way, you only need to change your configuration, when the internal ranges is changed. This should not happen too often.

    Edit: Here is a question and answer about IP ranges (albeit in Java, but should be very simple to convert).