Error description:

I write a ASP.NET program, I use HttpContext.Current.User.Identity.Name to store users which visit our site. This program runs well when I debug in Visual studio and wee get display the login user successfully. However, the user name cannot be displayed when I run it in IIS 7.0. I'm very confused, why the program runs well at VS but fail at IIS?

Solution:

It's very obviouly that your IIS cannot get the username for the login one. It's because that you enable the anonymouos authentication in your IIS.  You should follow some steps as follows:

Firstly, open you IIS confiuation, Open "Authentication" in "IIS" folders. Just like:

 Secondly, modify the items below:

 Ok, now you have disabled the anonymouos authentication config and enabled the Windows Authentication config. And you can view the login name for "HttpContext.Current.User.Identity.Name" in your ASP.NET program which runs at IIS server.

Good Luck to you!

转载请注明: 转载自Knight.Liao's Tale
本文链接地址: HttpContext.Current.User.Identity.Name is NULL?


我猜您可能还喜欢: