如何在 Dot net core 中访问像 AUTH_USER 这样的 serverVariable

Posted

技术标签:

【中文标题】如何在 Dot net core 中访问像 AUTH_USER 这样的 serverVariable【英文标题】:How to access serverVariable like AUTH_USER in Dot net core 【发布时间】:2020-06-27 10:21:08 【问题描述】:

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

【问题讨论】:

【参考方案1】:

你需要使用Features,看来你需要IServerVariablesFeature

您的代码将如下所示:

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

【讨论】:

以上是关于如何在 Dot net core 中访问像 AUTH_USER 这样的 serverVariable的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Dot Net Core 中使用 JWKS 验证 JWT 令牌

dot net core 项目,在 site.js 中使用 jquery maxlength 和 count 插件

Angular + core 如何将文件数组从 Angular 上传到 Dot Net Core

如何使用jquery从dot net core mvc中的表中的下拉列表中显示选定的值

2. Note Dot Net Core CMD

使用自包含框架时,dot net core 3.1 的设置 CI 构建配置失败