Development Tip

ASP.NET MVC 3-다른 작업으로 리디렉션

yourdevel 2020. 11. 6. 20:44
반응형

ASP.NET MVC 3-다른 작업으로 리디렉션


홈 컨트롤러의 인덱스 작업을 다른 컨트롤러의 작업으로 리디렉션하고 싶습니다. 따라서 내 코드는 다음과 같습니다.

    public void Index()
    {
        //All we want to do is redirect to the class selection page
        RedirectToAction("SelectClasses", "Registration");
    }

지금은 0kB의 빈 페이지 만로드하고 아무 작업도 수행하지 않습니다. 나는 그것이 그 무효 반환 유형과 관련이 있다고 생각하지만 그것을 무엇으로 변경 해야할지 모르겠습니다. 여기서 문제는 무엇입니까?


메서드는 ActionResult유형 을 반환해야 합니다.

public ActionResult Index()
{
    //All we want to do is redirect to the class selection page
    return RedirectToAction("SelectClasses", "Registration");
}

의 결과를 반환해야합니다 RedirectToAction.


Void 대신 ActionResult를 반환 해야합니다.


return View (); 대신이 코드를 작성해야합니다. :

return RedirectToAction("ActionName", "ControllerName");

return RedirectToAction("ActionName", "ControllerName");

참고 URL : https://stackoverflow.com/questions/4909670/asp-net-mvc-3-redirect-to-another-action

반응형