0

我正在尝试将对象类型有一个参数传递给控制器​​。我尝试直接传递对象。这是一个例外:

`System.Web.Mvc.HtmlHelper<dynamic>` has no applicable method 
named `ActionLink` but appears to have an extension method by that name.  
Extension methods cannot be dynamically dispatched. Consider casting  
the dynamic arguments or calling the extension method without the  
extension method syntax.

即使我添加了类型转换的代码,但它仍然会抛出上面的编译错误

InProgressGrid.Column(header: "File Name", columnName: "FileName",format:(item) => Html.ActionLink(((string)item.FileName), "DownloadReport", (Domain.UserObject)item ,null))

有什么方法可以将多个参数传递给控制器​​操作方法

InProgressGrid.Column(header: "File Name", columnName: "FileName",format:(item) => Html.ActionLink(((string)item.FileName), "DownloadReport", new {FileName = item.FileName,PK= item.PartitionKey },null)),

现在,当我运行应用程序时,我只看到一个属性,即。FileName 被传递,但没有 PartitionKey 被传递给 Controller 的 action 参数。

全局路由是否有任何变化以使上述条件起作用?

4

1 回答 1

0

您需要添加一条路线:

routes.MapRoute(
    "ReportDownload",     // Route name
    "Reports/{PK}/{FileName}",                           // URL with parameters
    new { controller = "Reports", action = "DownloadReport", PK = "", FileName="" }  // Parameter defaults
);

只需将控制器名称替换为您的名称即可。

于 2012-11-05T20:49:41.907 回答