Windows验证时,需要配置IIS,把匿名验证设为disable,windows验证设为enable,window7 默认为匿名验证为enable,windows验证为disable。
否则会system.web.httpcontext.current.user is null, 这个值会是空的
具体设置方法如下:
-
Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI, see Navigation in IIS Manager (IIS 7).(打开IIS7并找到要设置的网站)
-
In Features View, double-click Authentication.
-
On the Authentication page, select Windows Authentication.
-
In the Actions pane, click Enable to use Windows authentication