我正在使用表单身份验证实现ASP.NET MVC项目 . 这个项目是部署并运行正常,但现在我需要获取当前的Windows用户,但我没有得到它 . 我试试这个:
. System.Security.Principal.WindowsIdentity.GetCurrent()名称:
但在IIS中使用此配置返回 NT AUTHORITY\NETWORK SERVICE or AUTHORITY\IUSR .
-
匿名身份验证=已启用 .
-
模拟=已禁用 .
-
表单身份验证=已启用 .
-
Windows身份验证=已禁用 .
-
基本身份验证=已禁用 .
当我尝试:
-
匿名身份验证=已禁用 .
-
模拟=已启用 .
-
表单身份验证=已禁用 .
-
Windows身份验证=已启用 .
-
基本身份验证=已禁用 .
System.Security.Principal.WindowsIdentity.GetCurrent() . 名称: Domain\User
I get the current user windows correctly 但是当我去网站时没有css样式并且存在javascript错误 .
Javascript错误:资源解释为样式表,但使用MIME类型text / html进行传输
我有这个网络配置:
<identity impersonate="true"/>
<authentication mode="Windows">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
我认为该错误导致IIS配置 . *所有文件夹权限:每个人
1 回答
我有同样的问题...我几乎尝试了一切,但没有任何效果 . 然后我在我的webconfig中添加了这一行并且它有效 .
<authorization> <deny users="?" /> </authorization>
还要确保您的身份验证模式设置为Windows .
<authentication mode="Windows" />
EG:
<system.web> <compilation debug="true" targetFramework="4.6.1" /> <httpRuntime targetFramework="4.6.1" /> <authentication mode="Windows" /> <authorization> <deny users="?" /> </authorization> </system.web>