action-filter

How-to test action filters in ASP.NET MVC?

Need some pointers for this. Found this and this, but I'm still kind a confused. I just want to mock ActionExecutedContext, pass it, let filter to work a bit and check result. Any help? Source of filter you can find here (it's changed a bit, but that's not a point at the moment). So - i want unit test, that RememberUrl filter is ...

Order of AuthorizationFilter applied to a controller/method

Hi, if I have two custom implementation of IAuthorizationFilter, and both of them applied to a method in a controller, how do we determine which filter is executed first? e.g. Declaration: public class MyAuthenticationFilter : FilterAttribute, IAuthorizationFilter public class MyAuthorisationFilter : FilterAttribute, IAuthorizationFil...

ASP.NET MVC - Access a controller property in an ActionFilter

Hello I'm using Unity to instantiate a new class into the controller constructor and save the injected class in a property inside the controller. Then I want to use an ActionFilter to see if the injected class has some properties that I validate inside it's constructor. So is there a way to use an ActionFilter to validade the properties...

asp.net mvc and recaptcha action

When a user submits a form, i'd like to show/redirect to the captcha page intermittently ( based on some custom rules ) and if validated, then execute/commit the first action Is there a way of doing this using the ActionFilter ? or any other way ? ...

Render different menus using ASP.NET MVC ActionFilters

Hi everyone! I have a standard menu using ul and li tags. And in my database, I have a table Users with a field 'certificate' and depending the value of this 'certificate', the user will see or not some items of the menu. I was reading some texts and I think I will have to use ActionFiltes. Is this right? So, how can I render differen...

ASP.NET MVC - Job of Controllers

Hello, I think I'm beginning to be confused with the job of a controller in MVC. I have a service that exposes five functions: list packages in queue get package delete package accept package deny package My ASP.NET MVC controller depends on this service, and can generally execute a service call on an Action. I'm happy so far. Th...

Is it possible to override the default behavior of [Authorize] in ASP.NET MVC?

Hello, I wondered if/how I can override the default [Authorize] behavior in ASP.NET MVC. I know that I can create a new Action Filter, make my own attribute and so forth; I am merely interested if I can simply change the [Authorize] behavior and replace its workings with my own code? Edit: Guys and Girls. I appreciate your input but as...

How to install an action filter in all actions in ASP.NET MVC?

Is there a way to have an action filter, like public class MyActionFilterAttribute : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext context) { ... be automatically applied to all actions in a web site? ...

Asp.NET MVC ActionFilter cannot get Form Submit data

I want to use custom action filter to manipulate parameters to one action. User inputs: 2 names in a form ; Action: actually needs to take 2 ids; Action Filter (onExecuting, will verify the input names and if valid, convert them into 2 ids and replace in the routedata) because i don't want to put validation logic in Action Controller...