Thursday, September 23, 2010

WCF and ASP.NET compatibility - the start

ASP.NET compatibility mode is useful for a project I'm doing, exposing WCF services that are implemented using pre-existing class libraries that were written for use in a WCSF application. There are many of these libaries, of high quality, and have made the WCF service implementations very compact and auto-debugged (as it were).

Because of their [the libraries] WCSF heritage, there is a dependency on constructions such as HttpContext.Current. Normally, WCF services are transport, binding (and so on) agnostic. But for this project, it was essential to activate ASP.NET compatibility - so that aspects such as HttpContext.Current, HttpContext.Current.Session were available, as well as useful side effects, like URL authorization being possible for .svc files.

Reading the Microsoft documentation, nothing could be simpler to enable. A few custom attributes sprinkled here and there, some specific bindings and behaviours if you wish - and you're done!

Unfortunately, it is not that simple. There are a few tweaks that are required, but which are indifferently documented. Next post lays out the 'pain free' way to enable compatibility mode.

No comments: