Silverlight client IP address and/or host name

Silverlight client IP address and/or host name

Old forum URL: forums.lhotka.net/forums/t/9991.aspx


JonM posted on Wednesday, January 26, 2011

Is there any way go get the IP address or hostname of a SL client?  It seems like the dataportal show be able to know this.  Any ideas?

RockfordLhotka replied on Wednesday, January 26, 2011

If you are hosting the data portal in IIS then it is effectively running in ASP.NET. Because that's the case, you can have a server-side assembly that references System.Web and thereby has access to the ASP.NET object model, and through the ASP.NET object model you can get at information about the request (probably via HttpContext.Current).

JonM replied on Saturday, January 29, 2011

That sounds like a good idea.  I am using IIS for my dataportal I've added a reference to System.Web on my server CSLA library.  In the data portal code I'm trying to get at the System.Web.HttpContext.Current.  It is null.  I'm not sure what that means.

RockfordLhotka replied on Saturday, January 29, 2011

I think there's something you need to do in order to get WCF to enable some of these features (like HttpContext). I don't know the details off the top of my head though, sorry.

tmg4340 replied on Saturday, January 29, 2011

If you're using WCF, you need to use the AspNetCompatibilityRequirementsAttribute.  But that would have to be set on the WCF service, which would be the WCF DataPortal implementation for SL - right?  And I thought it was already set...

Maybe I'm missing something obvious, but I know that attribute has to be applied somewhere.

- Scott

JonM replied on Saturday, January 29, 2011

I'm looking at the CSLA source code.  The attribute is on the Csla.Server.Hosts.Silverlight.WcfPortal class.  [AspnetCompatiblityRequirements(RequirementsMode = Allowed)].   I tried setting it to required but that kills my data portal with a page not found error.  hmm..

RockfordLhotka replied on Saturday, January 29, 2011

I don't think you need to change the data portal host. I think you need to change your web.config.

Look at the Windows authn example from the Core 3.8 video series, or (probably) the Windows authn test project under Source\Csla.Silverlight.test\SecurityTest.

The reason that attribute was added was so the SL data portal could (optionally) support impersonation. I think the same web.config settings used to get that working are what you need (or similar anyway).

Copyright (c) Marimer LLC