问题
Can you suggest me some ways on how to identify if a user is accessing my web application internally or externally?
Some methods i tried are:
- Check browser URL (http, internal - https, external)
- using Request.isSecureConnection
I just need some additional insights.
BTW, i am using a Web Part.
Thanks.
回答1:
Basically, you could do that by checking the client's IP address. There are 3 ranges that can be treated as local (or internal) networks. The 3 ranges are (A , B and C classes)
10.0.0.0/8 (255.0.0.0) 24 bits
172.16.0.0/12 (255.240.0.0) 20 bits
192.168.0.0/16 (255.255.0.0) 16 bits
You can use bit wise masking to check if ip is in any of those ranges, just turn ip in HEX representation
254.245.245.254 = 0xfefefefe
来源:https://stackoverflow.com/questions/7989437/asp-net-check-if-user-is-internal-or-external