[英]How to get a client's computer name in asp.net core
I've tried with我试过
System.Net.Dns.GetHostEntry(HttpContext.Connection.RemoteIpAddress.ToString()).ToString();
but that didn't work.但这没有用。 I've also tried to use我也尝试使用
PCName = Dns.GetHostEntry(Request.ServerVariables["REMOTE_ADDR"]).HostName;
but this seems to be deprecated for Core但这似乎已被 Core 弃用
Try this.尝试这个。
using Microsoft.AspNetCore.Http;
using System.Net;
Dns.GetHostEntry(HttpContext.Connection.RemoteIpAddress).HostName;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.