111
This commit is contained in:
25
Service/Application.Web/Common/ComHelper.cs
Normal file
25
Service/Application.Web/Common/ComHelper.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace Application.Web;
|
||||
|
||||
public class ComHelper
|
||||
{
|
||||
public static string GetClientUserIp(HttpContext context)
|
||||
{
|
||||
var ip = context.Request.Headers["X-Forwarded-For"].FirstOrDefault();
|
||||
if (string.IsNullOrEmpty(ip))
|
||||
{
|
||||
ip = context.Connection.RemoteIpAddress.ToString();
|
||||
ip = ip.Replace("::ffff:", "");
|
||||
}
|
||||
if (ip.Contains(","))
|
||||
{
|
||||
ip = ip.Split(',')[0];
|
||||
}
|
||||
//var ip = context.Request.Cookies["kxUserIp"];
|
||||
//if (string.IsNullOrEmpty(ip))
|
||||
//{
|
||||
// ip = "0.0.0.0";
|
||||
//}
|
||||
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user