开发者

call other method before action call using asp.net mvc 2

开发者 https://www.devze.com 2023-01-20 00:45 出处:网络
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.

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.


Does this help http://msdn.microsoft.com/en-us/library/system.web.mvc.actionfilterattribute.onactionexecuting.aspx ?


You could implement your own controller factory, see here, and do whatever you like with the controller before you return it.


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"];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消