views:

61

answers:

2

I have been looking around but i don't see any spec for this, maybe i search a wrong keyword. But i'm here so i should ask something.. :)

I'm familiar with Authorize Attribute, but I think it only apply to Actions. What should i do if i want my whole application to authorize first before getting access to any actions?

It will be very pain to just repeat in every action to put [Authorize] tag on top of them.

Thank you very much

A: 

No, you can mark your controller with AuthorizeAttribute like an action. Check out here.

Mehdi Golchin
how about the whole application to be authorize. I have like 20 controller here.
DucDigital
IMO, you should use authorization section in the web.config.
Mehdi Golchin
+2  A: 

It is not quite correct that AuthorizeAttribute applies only to actions. It can also be applied to classes containing actions. If you have a base controller type for your application (which can be abstract, if you like), and every other controller is a subtype of that base type, then your entire application now requires authorization, with just a few characters of typing.

You should find a way to make AuthorizeAttribute work for you; this is the standard way of doing authentication in ASP.NET MVC.

Craig Stuntz