반응형
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
반응형
'Development Tip' 카테고리의 다른 글
C #의 부분 클래스는 잘못된 디자인입니까? (0) | 2020.11.07 |
---|---|
프로그래밍 방식으로 CenterX / CenterY 제약 추가 (0) | 2020.11.06 |
System.Windows.Forms를 사용할 수 없습니다. (0) | 2020.11.06 |
CREATE FILE에서 운영 체제 오류 5가 발생했습니다 (이 오류에 대한 텍스트를 검색하지 못했습니다. 이유 : 15105). (0) | 2020.11.06 |
mongodb에서 콘솔을 지우는 방법 (0) | 2020.11.06 |