如何在Silverlight页面中获取窗口用户名。
我尝试使用以下链接,但它会留空。
http://blogs.msdn.com/b/keithmg/archive/2010/12/11/silverlight-get-user-or-windows-credentials.aspx
Get current Windows user name within Silverlight
http://www.codeproject.com/Articles/47520/Silverlight-Windows-User-Identity-Name
任何帮助都会得到高度赞赏
先谢谢, Hitesh
答案 0 :(得分:0)
步骤1:在default.aspx页面
的Page_Load()中添加以下代码String WindowsUserName;
System.Security.Principal.IPrincipal User;
User = System.Web.HttpContext.Current.User;
WindowsUserName = User.Identity.Name;
Char[] Spliter = { '\\' };
String[] user = new string[2];
user = WindowsUserName.Split(Spliter);
//WindowsUserName = user[1]; //" + WindowsUserName;
InitParams += ",WindowsUserName=" + WindowsUserName;//",WindowsUserName=ram";
步骤2:在Silverlight应用程序的App.xaml页面的Application_Startup()中添加以下代码
string msWindowsUserName = e.InitParams["WindowsUserName"];