2

Ok so I got action that is in controller and code is:

[HttpPost]
public ActionResult SaveRow(int? id)
{
    //some db operations.
    return RedirectToAction("Index");
}

and in view I got

@Html.ActionLink(Translation.Accept, "SaveRow", new { id = item.New.RecId })

I got error 404 when I click button is possible to run this action without redirecting to url /SaveRow/ ? Maybe this button is used wrong I'm new in mvc5 so be patient.

Dan Atkinson
  • 11,046
  • 14
  • 81
  • 111
vivid
  • 1,065
  • 2
  • 14
  • 33
  • 3
    Links are `GET`, you have marked the method as `POST`. Use [a form](http://msdn.microsoft.com/en-us/library/dd492590(v=vs.118).aspx) to reach it. – GSerg Oct 01 '14 at 08:21

1 Answers1

5

As documented here :-

2.An hyperlink or anchor tag that points to an action will ALWAYS be an HttpGet.

Try below code putting GET, as by default it takes [HttpGet] so remove [HttpPost] attribute

[HttpGet]
public ActionResult SaveRow(int? id)
{
    //some db operations.
    return RedirectToAction("Index");
}

and as an ideal design of MVC I would suggest you to use @Html.BeginForm to access pertiular POST call of edit functionailty

AlexB
  • 6,970
  • 12
  • 51
  • 71
Neel
  • 11,427
  • 3
  • 42
  • 60