I have a MVC project, and I'm using IHttpContextAccessor in order to use HttpContext in my controller.
public RequestController(IHttpContextAccessor accessor)
{
_contextAccessor = accessor;
}
I use another function in order to find out the name of the user that in the website.
So, I create a HTTP request, and then I get the user name in that way:
_contextAccessor.HttpContext.User.Identity.Name
In debug mode everything look fine and when I'm routing to: localhost/user I get my user name, but when it's not debug mode and it's locally or from IIS it just return NULL.
Anyone have an idea why?
CodePudding user response:
Finally I understood that I need to disable anonymous authentication from the server in IIS.