HttpContextAccessor.HttpContext.User.Identity..Name在VS2017中工作的IIS中为空 [英] HttpContextAccessor.HttpContext.User.Identity..Name is empty in IIS working in VS2017

查看:123
本文介绍了HttpContextAccessor.HttpContext.User.Identity..Name在VS2017中工作的IIS中为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.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.

在IIS上放置验证配置的地方

配置

这篇关于HttpContextAccessor.HttpContext.User.Identity..Name在VS2017中工作的IIS中为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆