-1

我希望IformcollectionnopCommerce 4.0 中的数据获得空值。

这是我在控制器中的 post 方法

[HttpPost]
public ActionResult UpdateCart(int Id, IFormCollection form)
{
  var setting = settingService.LoadSetting<DemoSetting>(_storeContext.CurrentStore.Id);

  //Check plugin is enabled or not
  if (!_setting.DemoSettingEnabled)
      return Content("");

  //Check null value
  if Id,<= 0)
    throw new ArgumentNullException("Id,");

这是我的视图页面,我可以从中发布数据

 <form asp-controller="DemoDiscounts" asp-action="UpdateCart" asp-antiforgery="true"
          asp-route-Id="@Model.Id" asp-route-id="product-attributes-form" > 

您能否建议是否有人有解决方案?

4

2 回答 2

2

嘿你可以试试这个希望对你有帮助

<form method="post" asp-controller="YourControllerName" asp-action="YourActionName" asp-route-Id="@Model.Id" id="product-attributes-form" role="form">

您忘记了 Method="Post" 的主要内容并给予 id="product-attributes-form" role="form" 希望它对您有所帮助

于 2017-11-30T13:14:36.703 回答
1

您需要在标签中添加角色参数

IErole="form"

<form method="post"  role="form">

...
...
</form>
于 2017-12-01T04:36:09.877 回答