HttpContextAccessor.HttpContext.User.Identity..Name在VS2017中工作的IIS中为空 [英] 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 Autentication;2禁用匿名认证.
You can open IIS and: 1-Activate Windows Autentication; 2-Disable Anonymous Autentication.
这篇关于HttpContextAccessor.HttpContext.User.Identity..Name在VS2017中工作的IIS中为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!