在Visual Studio中,我使用他們提供的模板創建了一個全新的ASP.NET Web窗體應用程序。如何在新的Web應用程序的Global.asax中實現User.Identity.Name
我還沒有做什麼到VS自動生成除了添加以下的global.asax.cs
string myself = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
string me = User.Identity.Name;
字符串自己保存我當前的Windows成功登錄ID代碼。但字符串我是空的,因爲當我調試時,用戶爲空。但是,Visual Studio在調試之前顯示沒有錯誤。
如何使用User.Identity.Name獲取正確的字符串值?
是的,這有訣竅。我之前有了Application_Start()中的代碼。 – Krondorian
...和WindowsIdentity和User.Identity之間的一個很好的對比。 – Rap