문제

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

도움이 되었습니까?

해결책

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();
      }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top