IIS 7.5 ASP.net 4.0 C# 4.0
这里的函数是线程安全的吗?假设同时来自不同访客的 1000 个不同的电话
public static string ReturnIpAddress()
{
string srUserIp = "";
try
{
if (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
{
srUserIp = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
if (string.IsNullOrEmpty(srUserIp))
{
srUserIp = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
}
}
catch
{
}
return srUserIp;
}