simplecart POST 数据的格式是什么?未能在 MVC 项目中获取 POST 数据

What format does simplecart POST data in? failing to get the POST data in MVC project

我已经运行翻墙了,请问simplecart如何获取POST数据?我试过接受一堆不同的数据类型,但我得到的都是空值。

用于简单购物车设置的 JS:

<script>
simpleCart({
currency: "AUD" // set the currency to pounds sterling
});

simpleCart({
    cartColumns: [
    { attr: "name" , label: "Name" } ,
    { attr: "size", label: "Size"},
    { attr: "price" , label: "Price", view: 'currency' } ,
    { view: "decrement" , label: false , text: "-" } ,
    { attr: "quantity" , label: "Qty" } ,
    { view: "increment" , label: false , text: "+" } ,
    { attr: "total" , label: "SubTotal", view: 'currency' } ,
    { view: "remove" , text: "Remove" , label: false }
    ]
});

simpleCart({
    checkout: {
        type: "SendForm",
        url: "umbraco/surface/cart/cart"
        }
    });
</script>

我的 MVC 控制器:

// POST: cart
    [HttpPost]
    public ActionResult cart(string contents)
    {
        var test = JsonConvert.DeserializeObject(contents);
        return null;
    }

有人知道如何解决这个问题,让它真正读入控制器吗?我尝试用与购物车相同的数据制作模型,但仍然为空。

我只需要一个由 simplecart 发送的变量列表,这样我就可以正确使用我的控制器。

我使用了 get 调用,然后是 Request.Form 调用来找出 SimpleCart 发送的变量。

结果我需要使用上面提到的 request 方法,因为 simplecart 只是将项目及其所有详细信息添加到最后,而不是使用 JSON字符串或任何东西。

列表如下,请注意第 6 项以上的项目与您拥有的项目一样多:

  1. 货币
  2. 运费
  3. 税收
  4. 税率
  5. itemCount
  6. item_name_1
  7. item_quantity_1
  8. item_price_1
  9. item_options_1

为了其他在 mvc 中使用 simplecart.js 的人的利益,我已经回答了我自己的问题,如果有人有比使用请求获取可变数量的 post 条目更优雅的解决方案,请post.