问题描述
<script>functiontest(){varno={no:"SPH"};$.ajax({type:'POST',url:'/API/B2B/GetNo',data:JSON.stringify(no),//date:{"":"SPH"},success:function(msg){alert(msg);}})}</script>
上边是htmljs代码,下边是类publicclassNo{publicstringno_{get;set;}}
API控制器publicclassB2BController:ApiController{//POST:api/B2B[HttpPost]publicstringGetNo([FromBody]Nono){string_tmp="";returnno.no_;}
为什么接收不到值no=null???
解决方案
解决方案二:
[HttpPost]publicstringGetNo([FromBody]Nono){string_tmp="";returnno.no_;}
这个是API控制器
时间: 2025-01-20 15:08:14