在本地主機我的用戶名是 'MTA' 調用此代碼時:如何在ASP.net中獲得客戶機用戶登錄?
string opl = HttpContext.Current.User.Identity.Name.ToString();
TextBox1.Text = opl.Substring(opl.IndexOf(@"\") + 1);
或本規範:
string opl = System.Environment.UserName.ToString();
TextBox1.Text = opl.Substring(opl.IndexOf(@"\") + 1);
但發佈和訪問從Windows Server網站之後。我的用戶名現在是'SRVCMAN'。
什麼是你想怎麼辦? – 2011-05-25 10:26:37
我只需要知道正在使用我的網站的用戶。 – SamekaTV 2011-05-25 10:33:52
但是不同的人可以在不同的設備上擁有相同的用戶名。在這裏獲取用戶名有什麼好處? – 2011-05-25 10:36:56