Wednesday, 5 December 2007

Request Context always null in WCF

I couldn't understand why my RequestContext was always null (OperationContext.Current.RequestContext) especially when it used to work - then I remembered that I had modified the code to transmit datagrams so I could bind to a msmq. This meant I had modified the Operation Contact to specify it was one way. Simply setting isoneway=false will allow two-way transmission and give you back your request context!

[Update]

This makes loads more sence if you understand how channels work in WCF - take a peek at page 170 of Inside windows communication foundation by Justin Smith (ISBN: 978-0-7356-2306-4)

[/Update]

Easy!

Ross