HttpContextAccessor.HttpContext.User.Identity..Name is empty in IIS working in VS2017

南楼画角 提交于 2021-01-28 05:11:08

问题


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);

The values of httpContextAccessor.httpContext.user.identity.name are retained properly for further requests and works in VS2017.

But on deploying to server with IIS the same code doesnt work and the values for httpContextAccessor.User.Identity.Name is returning empty.

Any idea what the problem is?

Thanks


回答1:


You can open IIS and: 1-Activate Windows Autentication; 2-Disable Anonymous Autentication.

Place on IIS where is autentication configuration

Configurations



来源:https://stackoverflow.com/questions/59737989/httpcontextaccessor-httpcontext-user-identity-name-is-empty-in-iis-working-in-v

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!