C# ASP.net Test if user comes from Local Network
I want to use C#/ASP.net to find out whether the user browsing the website is on the same network so that certain links are only displayed while in the office (to those who have access to them).
Anyone accessing from within the office will be doing so by going to it's 开发者_C百科local IP address (i.e. 192.168.x.x) whereas external users will be browsing to the public domain name.
All I need is some way to differentiate between the two types of user.
if (Request.UserHostAddress.StartsWith("192.168"))
{
//localuser
}
Take a look @ Request.Url.Host - you'll be able to pluck the address from this.
精彩评论