如何访问 Dot net 核心中的 AUTH_USER 之类的服务器变量

How to access serverVariable like AUTH_USER in Dot net core

在标准框架中,我们可以context.user.Request.ServerVariables.Get("AUTH_USER");但是如何在dot net core中访问类似的变量

您需要使用Features, it seems you need IServerVariablesFeature

您的代码将如下所示:

var svf = httpContext.Features.Get<IServerVariablesFeature>();
var authUser = svf == null ? "No feature :( Do you have IIS?" : svf["AUTH_USER"];