views:

268

answers:

3

I have seen this question posed regarding silverlight 2 but I have not seen any questions about silverlight 4.

Is there a way to get the current user running an application in silverlight 4.0? I thought I remember seeing that as one of the features of 4.0 but I cannot find it. (Maybe it was just wishful thinking on my part.) I would imagine it would have to come from the OS running the browser or the browser itself. (The application is not being installed locally, it's running in the browser)

I have a solution where I call web service method that just does the following to get the users name. However, I would like to not have to call a web service

HttpContext.Current.User.Identity.Name.ToUpper();

Thanks in advance!

Justin

A: 

I have been looking for the same thing, but as far as i have found, it is still not possible.

Someone posted an ASP.Net workaround here http://stackoverflow.com/questions/1176566/get-current-windows-user-name-within-silverlight but i have not had a chance to try it yet

Mike
A: 

You might find it easier just to pass the name into the silverlight app as a parameter

mcintyre321
How would I do this if a user is hitting the application from a url? For example, http://myapplication/mytestpage.html. Are you suggesting passing a parameter as a query string on the example above? So it would be http://myapplication/mytestpage.html?user=NewUser ??
JKC
if you can dynamically change the page context (as in an aspx or mvc view) http://nerddawg.blogspot.com/2008/03/how-to-pass-initialization-params-to.htmlinstead of startPage=Page1 write username=<%= User.Identity.Name %>
mcintyre321
if you really need to, have Silverlight interrogate the current url for the username
mcintyre321
A: 

Getting the Username client-side in standard Inbrowser silverlight app just isn't going to happen, it would be a really bad thing security wise if it were possible.

Personally if I had this requirement I would probably use some web service, WCF or a simple IHttpHandler server-side. However I would be in inclined to call it something like "UserContext" and send XML. The XML would contain the Username. This would allow for additional user specific state to be added to the XML later as further requirements become clear. Adding these new chunks of info would be easy.

AnthonyWJones