Thursday, June 27, 2013

Custom WCF Bahavior GOTCHA

WCF also provides a higher-level runtime that sits on top of the channel layer, targeted more at the application developer. It is often referred to throughout the WCF documentation as the service model layer. This higher-level runtime consists primarily of a component called the dispatcher (within the context of a service host) and a component called the proxy (within the context of a client). The dispatcher/proxy combination serves one primary purpose—to translate between WCF Message objects and Microsoft® .NET Framework method calls (see Figure). These components follow a well-defined sequence of steps to perform this process, and at each step along the way they provide extensibility points that you can plug into. You can use these extensibility points to implement a wide variety of custom behaviors including message or parameter validation, message logging, message transformations, custom serialization/deserialization formats, output caching, object pooling, error handling, and authorization, to name a few. Here I'll focus on the implementation of these types of custom behaviors
Figure : WCF Runtime Architecture

When you add a custom behavior to a WCF service to intercept calls before the operation is invoked, you need to add the Fully-Qualified Type Name (FQTN) into the web.config file like the following example.

<behaviorExtensions><add name=”MessageInspector” type=”MessageInspector.MessageInspectorEndpointBehaviour, MessageInspector Version=1.1.0.0, Culture=neutral, PublicKeyToken=2a8e0f2687fa1def″ /></behaviorExtensions>

How to find the Fully Qualified Assembly Name(FQAN) of a GAC registered assembly called 'MessageInspector'?

Command: GACUTIL.EXE /L MessageInspector
Result = MessageInspector, Version=1.1.0.0, Culture=neutral, PublicKeyToken=2a8e0f2687fa1def, processorArchitecture=MSIL


However if you then add the type name to that FQAN, the interceptor fails to execute. Why?
Well see the processor architecture directive at the end? REMOVE IT.
For some reason, Microsoft are doing a string comparison on the FQTN name when determining whether the WCF custom behavior is valid. As a result your WCF services will stop working.

Friday, April 19, 2013

Clean Sticky Footer

We had a requirement in one the of the web applications i am working on to have the footer stick to the bottom no matter what the height of the page content is. When i googled for this task, there are many solutions out there. In fact I experimented several of them to find that the footer hides some of the page contents when the content is larger than the height of the  page content height.

Finally found the solution at cleanstickyfooter which worked like charm.

I just wanted to mark this here first of all for my reference, and then for anybody who came here in search of a solution for a similar problem.