Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC3 Html.ActionLink Post

I have an MVC3 C#.NET web app and need to call a view using Html.ActionLink. I can't tell from the documentation if I can specify the POST or GET. Below is my HTML, is there a way to specify GET or POST?

 @Html.ActionLink("Create New", "Edit", "Subtask", 
                        new {Id = ViewBag.Id, Command="CreateHourEntry"}, null)
like image 415
MikeTWebb Avatar asked Dec 07 '11 19:12

MikeTWebb


2 Answers

If you want a post use Ajax.ActionLink but be aware it's an Ajax post. You could easily use jquery to cause your existing link to cause a form post but this functionality is not included in Html.ActionLink.

See ASP.NET MVC ActionLink and post method

like image 59
Adam Tuliper Avatar answered Sep 18 '22 18:09

Adam Tuliper


HTML hyperlinks send GETs.

To POST, you need to use a form.
or some Javascript

like image 33
SLaks Avatar answered Sep 17 '22 18:09

SLaks