MVC4를 사용하여 고객 객체를 나열, 생성, 편집 및 삭제할 수있는 간단한 테스트 웹 사이트를 만들려고합니다.MVC4 [HttpGet] 및 [HttpPost] 속성을 무시함
내 컨트롤러 안에는 컨트롤을로드 할 때 가져 오기 및 실제로 데이터를 저장하는 포스트가 있습니다.
The current request for action 'Create' on controller type 'CustomerController' is ambiguous between the following action methods:
System.Web.Mvc.ActionResult Create() on type [Project].Controllers.CustomerController
System.Web.Mvc.ActionResult Create([Project].Models.Customer) on type [Project].Controllers.CustomerController
내가 내 가져 오기 및 게시 방법의 차이를 볼 수없는 것을 이해 내 : 내가 프로젝트를 실행하고 만드는 작업을 액세스 할 때
//
// GET: /Customer/Create
[HttpGet]
public ActionResult Create()
{
return View();
}
//
// POST: /Customer/Create
[HttpPost]
public ActionResult Create(Customer cust)
{
if (ModelState.IsValid)
{
_repository.Add(cust);
return RedirectToAction("GetAllCustomers");
}
return View(cust);
}
그러나 나는 그 오류가 ,하지만 그 속성을 추가했습니다. 이 문제의 원인이 무엇이고 어떻게 다시 작동시킬 수 있습니까?
프로젝트를 지우고 다시 작성하십시오. –
과부하 또는 속성에 대한 속성을 acceptverbs에 추가해야합니다. http://stackoverflow.com/questions/436866/can-you-overload-controller-methods-in-asp-net-mvc – Zaki
이 코드는 괜찮아 보입니다. http 속성을 추가 한 후에 오류가 발생합니까? –