2017-02-13 60 views
0

的Web.Config Windows身份驗證顯示爲空的用戶名Windows身份驗證工作不asp.net的MVC顯示空

我的WebConfig認證是使

C#代碼 我試圖

WindowsIdentity.GetCurrent(); // showing null 
System.Security.Principal.WindowsIdentity.GetCurrent().Name // showing null 
System.Security.Principal.WindowsIdentity.GetCurrent().Name;// showing null 
Request.ServerVariables["LOGON_USER"] // showing null 
Request.ServerVariables["REMOTE_USER"] // showing null 
+1

你跟IISExpress託管呢?你有關閉匿名身份驗證。 – Fran

+0

是託管在IIS上,匿名身份驗證已關閉 – Agha

回答

1

有你這樣輸入是Web.Config

<system.web> 
    <authentication mode="Windows"/> 
</system.web> 
+0

我已經在webconfig中添加了此項 – Agha

0

在我的情況下,我檢查了項目屬性窗口。

匿名身份驗證已設置爲啓用並且Windows身份驗證 - 已禁用。我改變了這些值,它幫助了我。

enter image description here