如何在Silverlight页面中获取窗口用户名

时间:2014-07-30 07:08:00

标签: silverlight-4.0 silverlight-3.0 silverlight-5.0

1 个答案:

答案 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"];