views:

10

answers:

1

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...

http://stackoverflow.com/questions/46582/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 useful in FIlter.

A: 

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?

Simon