asp.net mvc 2 - Earlier ActionFilterAttribute execution in base controller - MVC2 -


i have following setup. when action executed in guestdetailscontroller, how can have[loadthemeinfo] run prior [requirecheckoutavailability] without having specify orders on child controller's attributes? filters use onactionexecuting.

[loadthemeinfo(order=1)] public class mgcontrollerbase : controller {  }  [requirecheckoutavailability(order=2)] public class guestdetailscontroller : mgcontrollerbase {  } 

from msdn: the order property takes integer value must 0 (the default) or greater, 1 exception. omitting order property gives filter order value of -1, indicates unspecified order. action filter in scope order property set -1 executed in undetermined order, before filters have specified order.

i prefer unspecifieds execute after specified order in case. there way trying achieve? maybe move load theme info code out of attribute , somewhere else?

set order in constructor of attribute. in order keep execution orders in 1 place , keep easy maintain new attributes added, create enum such as:

 public enum customactionfilterorder{      loadthemeinfo = 1,      requirecheckoutavailability = 2,  } 

and attribute constructor like

public requirecheckoutavailability(){     this.order = (int)customactionfilterorder.requirecheckoutavailability; } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -