views:

83

answers:

2

Hi

I am using asp.net mvc 1.0. I know asp.net mvc has a couple attribute classes such as "AuthorizeAttribute", ActionFilter? and I think there is like 2 more.

So I have made my own AuthorizeAttribute but I am not sure if this is the right one to use again or if I even need to inherit any of these built in classes.

What I am trying to do this is. Every time a user hits an action method I want to check if there subscription length has expired. If it has return them to the page to buy a new subscription otherwise let them go on their way.

I don't want to add this to my Custom AuthorizeAttribute because I have one plan that is free and thus does not need this. So I was thinking of having another sort of tag like this and put it under the AuthorizeAttribute this way if they are not authorized they get caught by that one. If they are but there subscription they get caught by the new one.

So how should I go out building this?

Thanks

+1  A: 

Your idea of building another ActionFilterAttribute is correct. Trick is to set the Order property on your filters and make sure they fire in the right order.

Wyatt Barnett
You got any tutorials on how to make an ActionFilter. I don't know too much about it. I thought AuthorizeAtrributeFilter always go first.
chobo2
Not sure of any tutorials, but it isn't too hard--just make a class that extends ActionFilterAttribute. Yes, the global authorization should be the first to fire.
Wyatt Barnett
Hmm I don't know if ActionFilter will work for me I need to redirect to another action but it won't let me since it is void.
chobo2
ActionFilterAttribute is what you want. What you probably want to do is redirect the response to a url rather than redirect the action.
Wyatt Barnett
How do I do a redirect to url?
chobo2
+1  A: 

As for tutorials and samples, check out:

Hope those help a bit !

marc_s
I am confused now does the ActionFilter always go after after the authroizetAttribute(unless you override the order.)? Or is it just the order they come in. I thought I read somewhere that authorize goes before ActionFilter.
chobo2