1、在NuGett安装 Microsoft.AspNetCore.Http
2、在 startup.cs 的 ConfigureServices 中注入
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
3、获取IP
Request.HttpContext.UserHostAddress().ToString();
1、在NuGett安装 Microsoft.AspNetCore.Http
2、在 startup.cs 的 ConfigureServices 中注入
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
3、获取IP
Request.HttpContext.UserHostAddress().ToString();