我如何在ASP.NET Core中实现IHttpRequestFeature

时间:2016-06-17 07:05:13

标签: c# .net

我使用红隼。

Reference

您是否有具体的实施示例?

1 个答案:

答案 0 :(得分:2)

我用它来查找ASP.NET Core API控制器的请求路径:

var httpFeatures = HttpContext.Features.Get<IHttpRequestFeature>();

 if (httpFeatures == null)
 {
    string path = httpFeatures.Path;
  }

返回路径“/ api / client / ipaddress / islocal”

参考:https://docs.microsoft.com/en-us/aspnet/core/api/microsoft.aspnetcore.http.features.ihttprequestfeature