Reputation: 5131
[HttpGet]
public ActionResult Products(int catid)
{
ProductNumbersFiltering pnf = new ProductNumbersFiltering();
var prodnumbers = pnf.getProductNumberFromID(catid);
return View(prodnumbers);
}
[HttpPost]
public ActionResult Products(int prodid)
{
return RedirectToAction("Details", prodid);
}
So the GET method receives a catalog id and returns all the products associated with that catalog. The POST method receives the product id and passes that on to the Details page. Since they both have the same method signature, MVC is rightfully complaining, but I can't think of a good way to make them different.
Anybody else run into this "problem"? How did you approach it/fix it?
Upvotes: 1
Views: 73
Reputation: 2812
Rename the post method to something else and use the ActionName
attribute:
[HttpPost]
[ActionName("Products")]
public ActionResult Products_Post(int prodid)
{
return RedirectToAction("Details", prodid);
}
Upvotes: 4