3
이상한 문제가 있습니다. 내보기 :Asp.Net mvc 중첩 동작 HTTPPOST
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@using(Html.BeginForm())
{
<input type="submit" value="asds"/>
}
@Html.Action("Index2")
내 컨트롤러 :
public class DefaultController : Controller
{
//
// GET: /Default1/
[HttpPost]
public ActionResult Index(string t)
{
return View();
}
public ActionResult Index()
{
return View();
}
//
// GET: /Default1/
[HttpPost]
public ActionResult Index2(string t)
{
return PartialView("Index");
}
[ChildActionOnly()]
public ActionResult Index2()
{
return PartialView();
}
}
내가 버튼 [HttpPost]Index(string t)
클릭
[HttpPost]Index2(string t)
이 excuted 된 후
Index
에 대한 데이터를 게시하지 않았기 때문에
Index2
에 대한 작업이 나에게 정말 이상합니다. 내 논리는
HttpPost
대신
[ChildActionOnly()]ActionResult Index2()
을 말해 줍니 다.
왜 이런 일이 발생합니까? [HttpPost]Index2
작업의 이름을 바꾸지 않고 어떻게이 동작을 재정의 할 수 있습니까?
고마워, 나는 그것이 도움이 될 것 같아요. 그러나 실제로이 동작이 기본으로 사용되지 않는 이유를 이해할 수 없습니다. –