c# - .net 核心中的 httprequest.UserHostName

标签 c# asp.net-core .net-core

在 HttpRequest 上找不到 UserHostName 属性。在任何论坛上都没有关于它的内容。这个已经下架了吗?有什么想法吗?

最佳答案

接受的答案不正确。 someHttpContext.Request.Host 对应于 HTTP 请求中使用的 Host header 。例如:获取 http://example.org/test将生成 example.org

UserHostName 用于返回发出请求的客户端 IP 地址的 DNS 主机名(即 someHttpContext.Connection.RemoteIpAddress)。看起来唯一的办法是手动从 IP 地址解析 DNS 主机名,例如Dns.GetHostEntry .

关于c# - .net 核心中的 httprequest.UserHostName,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42852574/

相关文章:

c# - GetPathByAction 为 Dictionary<string,string> 创建错误的查询参数

c# - WebAPI返回类或错误的方法类型

c# - 从 .Net Core 控制台应用程序更新 Firebase Firestore 中的文档

azure - 从 Azure Datalake V2 下载多个文件时出现 System.Net.Http.HttpRequestException

c# - 有没有一种简单的方法可以在 WinForms 中实现 Checked Combobox

c# - 检查 Size 类型是否为空的正确方法是什么?

c# - aspnetVnext 核心 CLR 中缺少 System.Drawing 命名空间

c# - 带有 Entity Framework 6 的 Oracle ODP.Net - 从 TableView 中选择时出现 ORA-00955

c# - .net 核心 : Invalid property identifier character: {. 路径 'Logging',第 10 行,位置 2。Newtonsoft.Json.JsonTextReader.ParseProperty()

postgresql - 使用 Entity Framework 核心在postgresql中执行存储函数返回原语