开发者

Change or switch request data

I'd like to create filter which will switch request data. More precisely i'd like to change type of request inside filter (it have to be POST), add some values into post's Data, add return url, and redirect it to Controller's action which accepts only POST... and then in this action i'd like to return to first URL.

I've found something like...

Response.Redirect with POST instead of Get?

but i'm pretty sure i don't catch his idea completely and don't know is it usefu开发者_StackOverflow中文版l in FIlter.


I've not found how to change request data... but useful was to

var controller = new MyController();
controller.ControllerContext = filterContext.Controller.ControllerContext;
controller.<action>(<parameters>); // it's action which accepts only POST, but here it doesn't matter
base.OnActionExecuting(filterContext);

Is there any better way to pass context or mayby... invoke Controller from current context? instead of creating new controller and calling his action?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜