This commit is contained in:
Putoo
2026-05-20 18:32:54 +08:00
parent 2c85872abd
commit 784bc66ef6
51 changed files with 1818 additions and 106 deletions

View 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;
}
}