Post方法的Html.ActionLink

时间:2013-07-29 01:10:19

标签: c# asp.net asp.net-mvc post get

有什么方法可以使用html.actionLink发布数据吗?

    public ActionResult Test()
    {
        return View();
    }

    [HttpPost]
    public ActionResult Test(TestModel test)
    {
        return View(test);
    }

并且在我看来......

    @Html.ActionLink("ClickMe","Test", new {Test1 = "actionLink", Test2 = "actionLinkDidThis"}, FormMethod.Post)  

这个动作链接是否可以通过httpPost方法而不是httpGet方法获得?

1 个答案:

答案 0 :(得分:0)

这将呈现一个锚标记,它将产生一个get请求,因为它是一天结束时的常规超链接。 您可以通过在其上放置HttpGet属性来将action方法设置为Get方法。 MVC模型绑定器也能够将Get请求反序列化为TestModel对象以获取Get请求。

如果您需要帖子请求,我会使用按钮并填写表格帖子

相关问题