Are there different callbacks available in asp.net like rails provide before_validation, before_update, befor开发者_Python百科e_save and before_destroy?
How to handle this scenarios in asp.net?
Take a look at the concept of Filters in ASP.NET MVC and also to the following 4 methods in the controller base class: OnActionExecuting, OnResultExecuting, OnAuthorization, and OnException.
http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.onactionexecuting.aspx-
Update On a second though I just realize that you might be looking for methods at the Model level and I answered from the Controller level. Unfortunately from what I understand that ASP.NET MVC does not provide as much at the Model level as Ruby On Rails does.
It looks like the link is broken so i'll pitch in.
In MVC you would use Action Filters
http://www.asp.net/mvc/tutorials/understanding-action-filters-cs
edit (I see you tagged as mvc but anyhow)
In Web Forms the onLoad method is run before each page action
Using a base class can span it over multiple pages
精彩评论