如何解决ASP.NET CORE 3 frombody NULL 与 Bootstrap Table 插件
我正在尝试根据引导表中的这个示例进行操作 query params。但是我收到的参数总是NULL,即使我在调用后端之前已经设置了它。我希望收到的价值应该是供应商。谢谢
查看
<table id="supplier-inBox-table" class="table table-bordered table-striped text-center bootstrap-table"
data-toggle="table"
data-query-params="InBoxTableParams"
data-url="/AppService/Get_InBoxTableData"
data-method="post"
data-pagination="true"
data-side-pagination="server">
<thead class="thead-dark">
<tr>
<th data-checkBox="true"></th>
<th data-field="ID" data-sortable="true">ID No</th>
<th data-field="Customer" data-sortable="true">Customer</th>
<th data-field="StoreCode" data-sortable="true">Store Code</th>
</tr>
</thead>
<script>
function InBoxTableParams(params) {
params.UserType = 'supplier';
return params;
}
</script>
控制器
[HttpPost]
public string Get_InBoxTableData([FromBody] InBoxTableData inBoxData)
{
return inBoxData.UserType;
}
模型
public class InBoxTableData
{
public string UserType { get; set; }
}
解决方法
当你调用Get_InboxTableData时,你会得到三个参数,UserType,offset and limit
。所以你可以尝试使用
public class InboxTableData
{
public string UserType { get; set; }
public int limit { get; set; }
public int offset { get; set; }
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。