0

****UPDATED****

I have a custom ContentActionInvoker that has some crazy logic in it.

I'd like in some case to invoke a different action in a diffrent controller and with some different parameters.

How can this be done?

class ContentActionInvoker : ControllerActionInvoker
{
        protected override ActionResult InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary<string, object> parameters)
        {
           ....
        }
}

3 Answers 3

1

Why do you need to redirect the user's experience back through the webserver (forcing the browser to make a round-trip) to access another class that is operating in the same AppDomain as the code that received the request from the MvcHandler?

If you want process data in another method, with different parameters, just instantiate that other class (or controller, which is just another class...) and either return the ActionResult generated by THOSE methods, or reformat your own ActionResult for the View requested.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Jeff, that's what I'd like to do, how can I do it? can you refer any code examples?
0

Don't you want to use RedirectToAction("MyAction")?

5 Comments

Dang, missed by less than a minute. :)
And I'm at work too, being busy answering questions on SO of course ;)
hehe, nice. I'm home with little else to do.
I've might been missing something, but I have now method called RedirectToAction. I'm not in a action, and this should happen before I have a action.
@CD: Just update your question to reflect these details you've just given. Tell us exactly where you're wanting to do this from your MVC application. Typically you want to do redirects from controller actions. If it's not from an action then there might be something more that needs doing.
0

Have you tried RedirectToAction or am I off base?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.