How to call the look of another controller in mvc4

I have 2 controllers, SearchController and DetailsController .

SearchController contains 2 views that contain the form.

I want to redirect to view the detail controller in the [HttpPost] action of my view in SearchController

Is it possible?

+7
source share
1 answer

You can try RedirectToAction if you do some processing on the first controller and then send the result to another controller.

View

 using(@Html.BeginForm("firstaction", "search", FormMethod.Post)){ // form stuff } 

controller

 public class SearchController { [HttpPost] public ActionResult FirstAction() { // do initial processing in the first controller // eg persisting changed on Edit Screen return RedirectToAction("SecondAction","Details"); } } public class DetailsController { public ActionResult SecondAction() { // do remaining processing in the first controller // fetching data for a grid and displaying the grid of items return View(); } } 
+6
source

All Articles