Sitecore 7.1 MVC渲染助手传递变量

Kom*_*u85 10 rendering sitecore razor sitecore-mvc sitecore7.1

我正在尝试将控制器返回的视图静态添加到我的视图中.在标准MVC中,我会做类似下面的事情.

@{Html.RenderAction("Product", "ProductListing", new {productId = product.ItemId});}
Run Code Online (Sandbox Code Playgroud)

这是我的控制器

[System.Web.Http.HttpGet]
public ActionResult Product(ID productId)
{
 var product= _productRepositorty.GetProduct(productId);

 return View("~/Views/Product/ProductDetails.cshtml", product);
}
Run Code Online (Sandbox Code Playgroud)

所以使用Sitecore渲染助手我有下面的内容,其中ID是Sitecore中的渲染项目,指向上面的控制器和操作.但是我无法将productId作为参数传递给Product操作(productId始终为null).这是将变量传递给另一个动作的正确方法吗?

@Html.Sitecore().Rendering("{AA6C2188-1897-4577-BE0A-25DD2BBA8AF1}", new { productId = product.ItemId })
Run Code Online (Sandbox Code Playgroud)

小智 4

据我所知,不支持此语法来传递要插入到操作中的参数。

您指定的参数将放入rendering.Properties集合中。

是否可以重写操作签名并使用RenderingContext.Current.Rendering.Properties内部读取值?