在 VS2017 中工作的 IIS 中的 HttpContextAccessor.HttpContext.User.Identity..Name 为空 [英] HttpContextAccessor.HttpContext.User.Identity..Name is empty in IIS working in VS2017
问题描述
我有一个 .net core 2.2 Web 应用程序,其中使用以下代码进行登录
I have a .net core 2.2 web application where the Signin happens using the following code
await _httpContextAccessor.HttpContext.SignInAsync(
CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentity),
authProperties);
httpContextAccessor.httpContext.user.identity.name 的值被正确保留以供进一步请求并在 VS2017 中工作.
The values of httpContextAccessor.httpContext.user.identity.name are retained properly for further requests and works in VS2017.
但是在使用 IIS 部署到服务器时,相同的代码不起作用,并且 httpContextAccessor.User.Identity.Name 的值返回空.
But on deploying to server with IIS the same code doesnt work and the values for httpContextAccessor.User.Identity.Name is returning empty.
知道是什么问题吗?
谢谢
推荐答案
您可以打开 IIS 并:1-激活 Windows 身份验证;2-禁用匿名身份验证.
You can open IIS and: 1-Activate Windows Autentication; 2-Disable Anonymous Autentication.
这篇关于在 VS2017 中工作的 IIS 中的 HttpContextAccessor.HttpContext.User.Identity..Name 为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!