我想user_ip存儲在數據庫中,當他登錄所以我創建表,登錄歷史 這得到了IP作爲爲nvarchar(50),那麼我搜索,我發現這個方法返回的IP作爲字符串如何在數據庫asp.net中存儲用戶IP?
<i>
public string GetUser_IP()
{
string VisitorsIPAddr = string.Empty;
if (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
{
VisitorsIPAddr = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else if (HttpContext.Current.Request.UserHostAddress.Length != 0)
{
VisitorsIPAddr = HttpContext.Current.Request.UserHostAddress;
}
return VisitorsIPAddr;
}
</i>
但它存儲這樣的IP ::1
請幫助我!