asp.net Core API 获取ip地址

1.nuget 引用 Microsoft.AspNetCore.HttpOverrides

2.app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto });

3.使用

var ip = HttpContext.Connection.RemoteIpAddress;//ip地址
var port = HttpContext.Connection.RemotePort;//端口

 

asp.net Core API 获取ip地址

上一篇:DataGridView 设计


下一篇:win远程桌面mac