Пример #1
0
        public static HttpContext GetHttpContext()
        {
            object factory = CPAppContext.GetService(typeof(Microsoft.AspNetCore.Http.IHttpContextAccessor));

            Microsoft.AspNetCore.Http.HttpContext context = ((Microsoft.AspNetCore.Http.HttpContextAccessor)factory).HttpContext;
            return(context);
        }
Пример #2
0
        /// <summary>
        /// 获取客户端IP
        /// </summary>
        public static string GetClientIP()
        {
            try
            {
                object factory = CPAppContext.GetService(typeof(Microsoft.AspNetCore.Http.IHttpContextAccessor));

                Microsoft.AspNetCore.Http.HttpContext context = ((Microsoft.AspNetCore.Http.HttpContextAccessor)factory).HttpContext;

                var ip = context.Features.Get <IHttpConnectionFeature>()?.RemoteIpAddress?.ToString();
                return(ip);
            }
            catch (Exception)
            {
                return("未获取用户IP");
            }
        }
Пример #3
0
 public static CPAutoNumHelper Instance()
 {
     return(CPAppContext.GetService <CPAutoNumHelper>());
 }