[英]User authentication in asp.net or mvc
如何检查用户是否通过调用ASP.Net中的方法更改了IP地址?
I use the following to get user ip: 我使用以下命令获取用户ip:
public class UserIp
{
private string _StrIpAddress;
/// <summary>
/// Initializes a new instance of the UserIp class.
/// </summary>
public UserIp()
{
_StrIpAddress = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (_StrIpAddress == null)
_StrIpAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
public override string ToString()
{
return base.ToString();
}
}
您可以使用:
Request.UserHostAddress()
System.Web.HttpContext.Current.Request.UserHostAddress can be used to get the IP addess. System.Web.HttpContext.Current.Request.UserHostAddress可用于获取IP地址。 you can match userid with IP address.
您可以将用户ID与IP地址进行匹配。 you can check either after user login (session_start) or at the begining of each page (page_load method).
您可以在用户登录后(session_start)或在每个页面的开头(page_load方法)进行检查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.