Filters in ASP.NET MVC provide a great way to attach functionality around controllers. By building on top of the MVC framework, my ResourceUri class (which inherits from Controller) gets all the filter goodness as well.
My library also has a SubResourceUri class. Any filters applied to the parent ResourceUri are also executed for the SubResourceUri.
[ResourceUriTemplate("customers/{CustomerId}")][MyLoggingFilter]public class CustomerUri : ResourceUri { ... }[ResourceUriTemplate("orders/{OrderId}")]public class OrderUri : SubResourceUri<CustomerUri> { ...}
For example, when we GET an order the filter still catches the request and outputs logging information.
Another use is authorization. You can place an authorization filter on top level URI and it will protect all sub-URIs beneath it.
Keep track of the latest developments on the code here: http://svn2.assembla.com/svn/snooze/branches/aspnet
Powered by: newtelligence dasBlog 2.2.8279.16125
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2010, Andrew Davey
E-mail