작은 asp.net mvc 응용 프로그램이 있습니다. 여기에는 Index.html 및 다음 코드 홈 제어 장치에 몇 가지 동작 링크가 있습니다.Asp.net MVC에서 한 컨트롤러에서 다음 이동하는 방법
편집 ActionLink을 편집하면 HomerController의 "편집"acton 메소드 (httpGet 유형)로 제어가 이동합니다. 해당 작업 메서드에 대한보기는 Edit.cshtml입니다. 해당 EDIT보기에서 일부 데이터 조작을 수행하고 그 데이터를 POST하려고하면 어떻게해야합니까? 동일한 HomeController에 다른 편집 작업 메서드 (httpPost)를 작성 하시겠습니까? 이 경우 제 집 컨트롤러가 더 커질 것입니까?
이 목적을 위해 별도의 컨트롤러를 작성해야 할 경우 해당 컨트롤러로 컨트롤을 어떻게 전송합니까? (내가보기 편집 내 새로 만든 편집 컨트롤러를 부착 어떻게 말인가요?)
List<StateCity> stateCityList = new List<StateCity>();
public ActionResult Index()
{
StateCity sc1 = new StateCity() { Id = 1, StateName = "Dallas", Cities = new List<string>() { "ab", "cd" } };
StateCity sc2 = new StateCity() { Id = 2, StateName = "Austin", Cities = new List<string>() { "ef", "gh" } };
stateCityList.Add(sc1);
stateCityList.Add(sc2);
return View(stateCityList);
}
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
public ActionResult Edit(int id)
{
return View();
}
내가 그나마 내가 다른 컨트롤러가 어떻게 알고와와 Index.cshtml의 링크에서 해당로 이동합니다. – Relativity
@Relativity가 답변을 업데이트했습니다. – Artiom