views:

2438

answers:

2

I have a controller action which I would like to call another controller action.

Is this a valid thing to do. Is it possible?

+5  A: 

Controller.RedirectToAction

Justice
This is issuing an HTTP 302 content redirect, involving a browser round trip. Is there a way to get rid of the round trip?
o_o
Controller actions are publicly visible HTTP endpoints. If you have two actions which need to do the same things, then what you need is either a set of nonpublic controller methods or a set of services.
Justice
inside the controller that you are calling enter return View("viewName", object); inside the other controller call return <controller>(params...)
AbeP
One could argue that Justice's point about Services is actually a more architecturally sound solution.
Visionary Software Solutions
+1  A: 

As @Justice says you can use RedirectToAction. Also, you can use TempData to pass model (and other) data between controller actions.

tvanfosson