MVC4 Ajax.BeginForm routeValues 在 HTML 中转换为类型名称

MVC4 Ajax.BeginForm routeValues converted to Type Name in HTML

我在 MVC 4 Razor 视图中使用 Ajax.BeginForm。

@model EditViewDefinition
@{
    RouteValueDictionary postParams = new RouteValueDictionary();
    postParams.Add("entityUid", Model.EntityUid);
    postParams.Add("entityId", ViewBag.entityId);
    postParams.Add("viewUid", Model.UID);
    string viewContainerId = "viewcontent_" + Model.UID.ToString().ToLower() + "_" + ViewBag.entityId.ToString();
}

然后

using (Ajax.BeginForm("Edit", postParams, new AjaxOptions() { HttpMethod = "Post", OnSuccess = "submitSuccess('" + viewContainerId + "')" }))
{
...
}

现在,当我在浏览器中检查结果 HTML 时,我得到:

<form id="form0" 
    action="/View/Edit?Count=3&amp;Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object%5D&amp;Values=System.Collections.Generic.Dictionary%602%2BValueCollection%5BSystem.String%2CSystem.Object%5D"
    method="post" 
    data-ajax-success="submitSuccess('viewcontent_fb1a8d4c-fd30-4da4-b11c-bff99f3bb74f_1')" 
    data-ajax-method="Post" 
    data-ajax="true"> 

    ... 
</form>

为什么我在操作属性中得到 System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object 而不是 action="/View/Edit?entityUid=uid&entityId=1&viewUid=uid?

感谢 Stephen Muecke 的评论。我使用了 var postParams = new { entityUid = Model.EntityUid, entityId = ViewBag.entityId, viewUid = Model.UID }; 有效。

非常感谢斯蒂芬。