HttpContext.Current.Request.UserHostAddress;
Run Code Online (Sandbox Code Playgroud)
要么
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
Run Code Online (Sandbox Code Playgroud)
要获取计算机的IP地址而不是代理,请使用以下代码
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
Run Code Online (Sandbox Code Playgroud)