Pergunta

I have 2 controllers, SearchController and DetailsController.

the SearchController contains 2 views which contain form.

I want to redirect to a view of the details controller on the [HttpPost] action of my view in the SearchController

Is this possible???

Foi útil?

Solução

You could try RedirectToAction if you are doing some processing in the first controller and then sending 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
          // e.g 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();
      }
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top