1

Is there a way to get the functionality of action filters in asp.net mvc where you can call and manipulate action parameters pre the method executing and post method call to update/view the return type data but in a standard c# class library class method?

1

1 Answer 1

2

This sounds a lot like aspect-oriented programming. PostSharp is an example of a tool that can help you get there. A common example is to have a class auto-implement INotifyPropertyChanged, which is boring or tedious, or to spit out a bunch of logging statements before and after a method call, without having to manually write that instrumentation in code.

Hope that gets you on the right track.

3
  • Tons of great examples here: google.com/… Nov 18, 2010 at 22:20
  • any open source alternative to postsharp you would recommend?
    – monkeylee
    Nov 18, 2010 at 22:39
  • I feel like PostSharp was open source at one time ... maybe it was just free to use. It looks like there is still a community edition that is free. I have used PostSharp in the past and it seems to work well. At a basic level, you could use Castle's DynamicProxy or LinFu, but the use case is different. At least now you know the magic words to search for! :) Nov 18, 2010 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.