I am trying to make a POST request from my View by calling an ActionResult in my Controller. Basically there are a list of events in the view and the user can view the details of the event by clicking the event. This part works. However, once they view the details they also have the ability to sign up for the event. This is the part which is not working.
A sample action I'm trying from the view:
@Html.ActionLink("SignUp", "SignUp", new {id = "2"}, null)
This should access this action result:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult SignUp(int id)
{
if (ModelState.IsValid)
{
var registratie = new Registratie(User.Identity.GetUserId(), id);
_db.Registraties.Add(registratie);
_db.SaveChanges();
return RedirectToAction("Index");
}
return View("Index");
}
However, I am getting a 404 error. I think it can't find the actionresult?
The details action result is on the same page however and that works:
// GET: /EventPlanner/Details/5
public ActionResult Details(int id)
{
var evenement = _db.Evenementen.Single(e => e.ID == id);
return View(evenement);
}
I don't understand why the signup gives a 404. Any ideas?