how can i tell if a page is being served on a local lan?

This does the trick. It detects external ip address from outside the lan and internal ipaddress from inside the lan. And if the page is accessed from an external LAN with a matching ipaddress, it still returns the external one.

protected void Page_Load(object sender, EventArgs e) {
String thisipaddress = Request.UserHostAddress;   <-----THIS

if (thisipaddress == "127.0.0.1" || strings.left(thisipaddress,7)=="192.168"){
    hiddenarea.Visible = true;
} else {
    hiddenarea.Visible = false;
}

}

https://docs.microsoft.com/en-us/dotnet/api/system.web.httprequest.userhostaddress#System_Web_HttpRequest_UserHostAddress

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top