ASP.Net check if user is internal or external

£可爱£侵袭症+ 提交于 2019-12-24 03:15:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!