开发者

How to get current User Name of Windows in silverlight?

开发者 https://www.devze.com 2023-01-26 16:34 出处:网络
I need to get the User Name of current Windows Login user. is there any way to do that in silverlight?

I need to get the User Name of current Windows Login user. is there any way to do that in silverlight? thanks in advanc开发者_如何转开发e.


Do you use Windows Authentification and asp.net page as host?

So deny anonymous users

<authorization>
    <deny users="?" />
</authorization>

and use this code:

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
...
    <param name="initParams" value="username=<%= User.Identity.Name %>" />
...
</object>

After that parse input params in the silverlight application:

private void Application_Startup(object sender, StartupEventArgs e)
{
    var username = e.InitParams["username"];
    this.RootVisual = new MainPage();
}

 

Also I know another way to achieve this (with wcf service), but it is more complicated.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号