开发者

C# ASP.net Test if user comes from Local Network

开发者 https://www.devze.com 2023-01-07 00:14 出处:网络
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).

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.

0

精彩评论

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