1

I have a form generated through Razor:

using (Ajax.BeginForm("SaveProfile", "Settings", new { AccountID = Model.AccountID },
    new AjaxOptions { HttpMethod = "Post" }))

The RouteValues object, new { AccountID = Model.AccountID } gets shoved into the Query String, even though I don't specify to do so anywhere in my project.

How can I pass these values to my controller action without letting them show up in the URL?

4

1 回答 1

2

MVC 模型绑定将识别查询字符串表单(发布)变量传递的值。

因此,您可以在表单中包含隐藏输入,其中 var 名称作为name属性,值作为value属性:

@Html.HiddenFor(model => model.AccountID)
于 2013-06-14T21:32:34.860 回答