MVC ActionFilter像WCF的属性 [英] MVC ActionFilter like attributes for WCF
问题描述
有没有一种方法可以为WCF创建自定义方法属性,使我可以轻松地使用前置过滤器装饰服务方法,就像MVC使用动作过滤器一样。我计划将它们用于身份验证和授权。这是针对RESTful服务的,其请求中带有身份验证cookie。
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.
我对如何创建属性而不是身份验证方面更感兴趣。 HTTP工具包提供任何东西吗?
I am more interested in how to create the attributes rather than the authentication side of things. Does the HTTP Toolkit offer anything?
谢谢
推荐答案
WCF有强大的可扩展性-在许多方面。您可以将许多功能封装到例如服务和/或操作行为,可以通过属性将其附加到服务或操作。
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.
查看当前 DotNet Rocks电视节目#202和Miguel Castro 关于WCF的可扩展性-它应该使您对可能的想法有所了解(当然还有更多的可能! )
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!)
另请参见:
- WCF Extensibility Samples
- WCF Extensibility Deep Dive
- WCF Extensibility Screencast
这篇关于MVC ActionFilter像WCF的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!