I recently completed work on an internal Silverlight app. The project was a blast – it really reminded me of how coding could be fun again. One of the surprising gaps I found in Sliverlight was the inability to get the current user context (e.g. determine the login domain and userid of the person viewing the page). I checked with the product team and they confirmed that this is not (yet?) a feature of Silverlight. While this feature may be provided at a later date, I needed it now. I was able to develop a workaround using ASP.NET’s LOGON_USER server variable using the following:
String userName = Request.ServerVariables["LOGON_USER"];
UID.Value = userName;
<form id="form1" runat="server" style="height:100%;">
<input type="hidden" name="userContext" id="UID" runat="server" />
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
document.write ("<object data=\"data:application/x-silverlight,\" type=\"application/x-silverlight-2-b1\" width=\"1150px\" height=\"810px\">");
document.write ("<param name=\"source\" value=\"ClientBin/MyApp.xap\"/> ");
document.write ("<param name=\"background\" value=\"white\" />");
document.write ("<param name=\"onerror\" value=\"onSilverlightError\" />");
document.write("<param name=\"initParams\" value=\"userID=" + form1.UID.value + "\"");
It ain’t pretty but it works. :)
PingBack from http://www.basketballs-sports.info/better-basketball/?p=1004
Yeah, Of course it works. Since silverlight can get prameters by passing the vlaue into his parameter format. And Cons still!
Can you simply use object tag or asp:Silverlight control directly instead of using document.write?
Michael: its probably possible, I haven't looked into it. I needed a quick and easy way to pass a dynamic parameter in and document.write seemed the easiest way to do it. Again, it isn't pretty but it works.
you can access the membership info via a webservice like described here:
I think you can get querystring variables with this:
(as in page.htm?key=pwd)