Search code examples
c#.netwcf

Action Filters in WCF Services


Is there something Like ActionFilterAttribute (From ASP.NET MVC) in WCF Services (Or anything like that). basically what I want to do is to log what is coming and goint to and from my services, and I don't want to write the logging code in every single ServiceContracts. yes the question is very general but you understand the idea what I want to do.


Solution

  • Yes there is it called as MessageInspectors/ParameterInspectors , here you can read about them http://msdn.microsoft.com/en-us/library/aa717047%28v=vs.110%29.aspx

    This is exactly what you are looking for , WCF custom behavior log logging http://www.codeproject.com/Articles/243352/LoggingBehavior-How-to-Connect-Log-prints-with-the

    Only confusing thing is you can have message inspector on WCF service and WCF proxy as well , in your case you need only for service side