在我的ASP.NET应用程序中我使用windows auth作为唯一的auth方法。
我可以在default.cs中读取登录用户:
HttpContext.Current.User.Identity.Name
现在,在我的应用程序中插入更多页面之后,需要在每个页面上读取用户名。
所以我在Global.asax中解雇了它,但结果是NULL。
我的web.config:
<configuration>
<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</configuration>
有什么想法吗?
-pic
答案 0 :(得分:1)
您可以使用can Thread.CurrentPrincipal.Identity.Name
,也可以在Application_BeginRequest()