In theory it is, because a view inherrits from ViewPage
, which inherrits the events from Page
. However it will be the Load
event (it probably wont be automatically wired to Page_Load
).
However, you almost certainly don't want to do this! In a normal MVC application there is no concept of code behind. Views (or anything 'behind' them) should not contain logic. This should go into you controller in small applications, or moved out into other layers in larger apps. The only reason you might want to do this is integration with some existing non-MVC apps, but even then it's very debatable.
UPDATE:
For security, yes you are on the right lines with your other suggestions. (You definately don't want to use Page_Load for this). MVC provides the AuthorizationAttribute
out of the box. You can apply it to controller classes (or base classes), and individual actions, and can specify authorised roles. It's fine for most scenarios. If you wanted to do something custom you could create a custom attribute.