ASP.Net检查用户是否是内部或外部 [英] ASP.Net check if user is internal or external

查看:134
本文介绍了ASP.Net检查用户是否是内部或外部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以建议我如何找出一些方法,如果用户内部或外部访问我的web应用程序?

Can you suggest me some ways on how to identify if a user is accessing my web application internally or externally?

一些方法我试过是:


  • 检查浏览器的URL(HTTP,内部 - HTTPS,外部)

  • 使用Request.isSecureConnection

我只是需要一些额外的见解。

I just need some additional insights.

顺便说一句,我使用的是Web部件。

BTW, i am using a Web Part.

感谢。

推荐答案

基本上,你可以做到这一点通过检查客户端的IP地址。有可以被视为本地(或内部)网络3的范围。
3范围是(A,B和C类)

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

您可以使用逐位掩码来检查是否IP是在任何的范围,只是把在HEX重新presentation IP

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

254.245.245.254 = 0xfefefefe

这篇关于ASP.Net检查用户是否是内部或外部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆