Reputation: 986
I want to call other method or other technique before action call in asp.net mvc 2.
Because I want to set property in variable then to call action in controller.
can any one guide me if possible.
Upvotes: 0
Views: 1070
Reputation: 702
If all you need to do set is set a controller member variable then a quick and clean method is to override the controller's initialize method like so:
protected override void Initialize( RequestContext rc) {
base.Initialize(rc);
//Add any variable initialization here
employeeId = rc.HttpContext.Request.Cookies["userid"]["emp_id"];
}
Upvotes: 0
Reputation: 1685
Does this help http://msdn.microsoft.com/en-us/library/system.web.mvc.actionfilterattribute.onactionexecuting.aspx ?
Upvotes: 2
Reputation: 28834
You could implement your own controller factory, see here, and do whatever you like with the controller before you return it.
Upvotes: 1