开发者

Silverlight Client UserName

开发者 https://www.devze.com 2023-02-26 18:52 出处:网络
I am trying to return the Client UserName back into Silverlight 开发者_如何学编程by using HttpContext.Current.User.Identity.Name in the .aspx page that starts the application.

I am trying to return the Client UserName back into Silverlight 开发者_如何学编程by using HttpContext.Current.User.Identity.Name in the .aspx page that starts the application.

I have this hooked up to InitParams working fine passing it into silverlight with the ASP.Net Development Server but when I change to an IIS Web site it returns an empty string.

All of our users will be on the same IP subnet with different domains. This is a intranet app. I need to know who they are, preferably without authenticating, in order to load the proper interface. I do not have any Windows or Forms authentication established in the app yet.

....is it possible?


Without authentication on the server-side, I believe this is not possible. You'll have to have the ASP.NET page authenticate in order for it to write the client's username into that init param.

The test web server's process is running as the local developer, it probably appears to be working since both the client and server are running as the same user.

Suggestion:

Enable Windows authentication in IIS for that application folder that hoses the ASP.Net page. Disable anonymous. This should (in theory) be fine for the intranet. At this point I think you should be able to get Authenticated user from HTTP context. We use Thread.CurrentPrincipal.Identity.Name since we're doing this in a WCF web service.

Not all browsers support Windows authentication. IE and Chrome seem to work the best. Firefox requires you to enable this per-site (look up the "trusted-uris" settings, note that Negotiate and NTLM are separate settings). Safari and Opera as well as non-windows clients, I'm not sure any more.

To get more consistent support across browsers look into the "alternative" client HTTP in Silverlight. However, I guess this wouldn't work with setting init params in the asp page. If you could make an additional request to another ASP page (or a web service) to get the user after loading you could choose to use this other http stack. I found it supports authentication itself, regardless of the browser.

0

精彩评论

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