【修复】多种环境下获取ip地址长度过长问题,使用MapToIPv4。

pull/122/head
JianWeie 3 years ago
parent 9f3d1d57b6
commit b4fde8254b

@ -581,7 +581,7 @@ namespace CoreCms.Net.Services
billPayments.type = type;
billPayments.status = (int)GlobalEnumVars.BillPaymentsStatus.NoPay;
billPayments.paymentCode = paymentCode;
billPayments.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
billPayments.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
billPayments.parameters = @params != null ? JsonConvert.SerializeObject(@params) : "";
billPayments.createTime = DateTime.Now;

@ -225,7 +225,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
var log = new CoreCmsUserLog();
log.userId = user.id;
log.state = (int)GlobalEnumVars.UserLogTypes.;
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
log.createTime = DateTime.Now;
log.parameters = GlobalEnumVars.UserLogTypes..ToString();
await _userLogServices.InsertAsync(log);
@ -313,7 +313,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
var log = new CoreCmsUserLog();
log.userId = user.id;
log.state = (int)GlobalEnumVars.UserLogTypes.;
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
log.createTime = DateTime.Now;
log.parameters = GlobalEnumVars.UserLogTypes..ToString();
await _userLogServices.InsertAsync(log);
@ -522,7 +522,8 @@ namespace CoreCms.Net.Web.WebApi.Controllers
var log = new CoreCmsUserLog();
log.userId = id;
log.state = (int)GlobalEnumVars.UserLogTypes.;
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ?
_httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
log.createTime = DateTime.Now;
log.parameters = GlobalEnumVars.UserLogTypes..ToString();
await _userLogServices.InsertAsync(log);

Loading…
Cancel
Save