2011-12-07 29 views
7

Tengo una aplicación web MVC3 C# .NET y necesito llamar a una vista usando Html.ActionLink. No puedo decir a partir de la documentación si puedo especificar el POST o GET. Debajo está mi HTML, ¿hay alguna manera de especificar GET o POST?MVC3 Html.ActionLink Post

@Html.ActionLink("Create New", "Edit", "Subtask", 
         new {Id = ViewBag.Id, Command="CreateHourEntry"}, null) 

Respuesta

7

si quieres un Ajax.ActionLink uso post pero tenga en cuenta que es un puesto de Ajax. Puede usar fácilmente jquery para hacer que su enlace existente cause una publicación de formulario, pero esta funcionalidad no está incluida en Html.ActionLink.

Ver ASP.NET MVC ActionLink and post method

6

hipervínculos HTML enviar GET.

Para POSTAR, necesita utilizar un formulario.
o algún Javascript

+1

@SLaks .... gracias .... puede ser que usted tiene un ejemplo de un formulario usando un POST? – MikeTWebb

+0

Use '@using (Html.BeginForm (...))' – SLaks

3

También puede utilizar Ajax.ActionLink donde puede especificar POST o GET

@Ajax.ActionLink("Create New", "Edit", "Subtask", 
        new AjaxOptions{ HttpMethod="Post"}) 
Cuestiones relacionadas