【发布时间】:2016-08-03 17:06:31
【问题描述】:
我制作了一个在右上角显示 Windows 用户名的 Web 应用程序。
如果我在 localhost:5903/index.aspx 上打开 webapp,我会得到正确的 Windows 用户。
像这样 -
但是如果我打开 localhost/db/index.aspx 我会得到 IIS AppPool User -
这里的 db 是我的应用所在的目录。
我不知道为什么会这样。我希望本地主机也显示正确的用户名。
我的 IIS 树,这里 DB(1) 是我的 webapp -
我选择 Windows 身份的 C# 代码 -
<li><% string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;%>
<a><%= userName %></a>
</li>
【问题讨论】: