MVC ActionFilter like attributes for WCF

2020-07-08 08:25发布

问题:

Is there a way I can create custom method attributes for WCF that allow me to easily decorate a service method with a pre filter much like MVC uses action filters. I plan to use them for authentication and authorization. This is for a RESTful service whose requests are carrying an authentication cookie.

I am more interested in how to create the attributes rather than the authentication side of things. Does the HTTP Toolkit offer anything?

Thanks

回答1:

WCF has great extensibility - in many ways. You can encapsulate lots of functionality into e.g. service and/or operation behaviors, which can be attached to a service or operation by means of an attribute.

Check out the current DotNet Rocks TV Show #202 with Miguel Castro on WCF extensibility - it should give you an idea of what is possible (and lots more is possible, for sure!)

See also:

  • WCF Extensibility Samples
  • WCF Extensibility Deep Dive
  • WCF Extensibility Screencast