I assume this is very simple, but now I'm learning MVC 2 and I'm stuck. I got a strongly typed view with some fields and buttons that should change something in the database by clicking on them. So this is the code
<% using (Html.BeginForm("UpVote", "Home",FormMethod.Post,new { linkId = link.LinkID }))
{%>
<input type="submit" value="UP" />
<% } %>
And my controller
[HttpPost]
public void UpVote(int linkId)
{
var updateLink = geekDB.Link.Single(a => a.LinkID == linkId);
updateLink.UpVotes++;
geekDB.SaveChanges();
RedirectToAction("Index");
}
And it does not work. When I click the button, the page reloads, but nothing happens. I tested it with a breakpoint in the UpVote method, but it never rests on its laurels, and I have no idea why.
source
share