ServicesResourcesConferencesOur TeamWeblogsAboutContact
   

Subscriptions

Post Categories

Affiliations

Archives

Beyond the Obvious: New Features and Fixes for WCF in .NET 3.5 - Accessing the remote hosts address

OK, this is first short blog entry on some new features (and fixes) for WCF in .NET 3.5 and/or 3.0 SP1.

I know that a number of people have been complaining bitterly about not being able to get the information of the calling remote host in WCF v1, i.e. the address or DNS name and maybe even the port number the client process is using for communication.
This is now fixed and we can access this information via the OperationContext in our service implementation (or any extension in the pipeline where we already have a valid OperationContext). From there we can pull a certain message property which gets populated down in the channel layer. This property is of type RemoteEndpointMessageProperty - here is the glory code that makes it easy to print out the remote host data:

RemoteEndpointMessageProperty rep =
  OperationContext.Current.IncomingMessageProperties[
    RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;

if (rep != null)
{
    Console.WriteLine("Remote caller: {0}", rep.Address);
    Console.WriteLine("Remote port: {0}", rep.Port);
}


Phil has some more information on what is going on under the cover of this.
That's it. Nothing spectacular here :)


posted on Monday, October 29, 2007 6:16 PM

# Link Listing - October 29, 2007 @ Tuesday, October 30, 2007 6:20 AM

ASP.NET ASP.NET MVC article in Code Magazine [Via: Jason Meridth ] Assembly Fun in ASP.NET [Via: Sean...
Christopher Steen

# New and Notable 199 @ Friday, November 02, 2007 6:48 PM

Last day of the conference and suffering from tiredness - was out with Marjan and her crew until 3 AM
Sam Gentile

# New and Notable 199 @ Saturday, November 03, 2007 4:23 PM

Last day of the conference and suffering from tiredness. BizTalk/CSD/Connected Systems/REST/Oslo My pal
Sam Gentile

# New and Notable 199 @ Monday, November 05, 2007 9:44 PM

Last day of the conference and suffering from tiredness. BizTalk/CSD/Connected Systems/REST/Oslo My pal
Sam Gentile

# New and Notable 199 @ Thursday, November 29, 2007 6:28 PM

Last day of the conference and suffering from tiredness. BizTalk/CSD/Connected Systems/REST/Oslo My pal
Sam Gentile

# New and Notable 199 @ Monday, December 03, 2007 4:32 PM

Last day of the conference and suffering from tiredness. BizTalk/CSD/Connected Systems/REST/Oslo My pal
Sam Gentile

# New and Notable 199 @ Monday, December 10, 2007 3:36 PM

Last day of the conference and suffering from tiredness. BizTalk/CSD/Connected Systems/REST/Oslo My pal
Sam Gentile

# New and Notable 199 @ Wednesday, December 12, 2007 12:29 AM

Last day of the conference and suffering from tiredness. BizTalk/CSD/Connected Systems/REST/Oslo My pal
Sam Gentile

# New and Notable 199 @ Tuesday, December 02, 2008 8:11 PM

<p>Last day of the conference and suffering from tiredness. BizTalk/CSD/Connected Systems/REST/Oslo My pal, Jon Flanders, who I spent a great deal of quality time with this week, made Workflow to BizTalk (XLANGs) Wizard as been released Jon also spent a lot of time talking REST and his example with BAM...</p>
Sam Gentile's Blog


Powered by Community Server, by Telligent Systems