在C#中获取“参数字典包含用于方法X的非空类型'System.Int32'的参数'ID'的空条目”

问题描述 投票:0回答:1

当我从exceptions.html的视图中运行此命令时>

 <tr ng-repeat="scbEXCEPtions in vm.scbExpData">
     <td>
       <button class="btn btn-alert btn-xs" ng-click="vm.DelExceptionObjRef(scbEXCEPtions.REF_ID)">
          Remove
      </button>
    </td>
 </tr>

并且在我的控制器文件exception.js中,这是我调用的方法

  vm.DelExceptionObjRef = function (refno) {
        vm.viewModelHelper.apiGet('api/scbexception/RevertExceptionById/' + refno, null,
        function (result) {
            vm.prepareData(result.data);
        },
        function (result) {
            toastr.error(result.data, 'Fintrak');
        }, null);
   }

单击时会生成此URL,即使在apicontroller文件上设置断点后,我也会收到此错误:

http://localhost:6861/api/scbEXCEPtion/RevertExceptionById/10000011943

并且我在Api控制器{ScbExceptionApiController}中有一个方法,可以在此处接收该函数和方法...

    [HttpGet]
    [Route("RevertExceptionById/{ID}")]
    public HttpResponseMessage RevertExceptionById(HttpRequestMessage request, int ID){
        return GetHttpResponse(request, () => {
            HttpResponseMessage response = null;
            ScbException[] scbexception = _APPModuleService.RevertExceptionById(ID);
            response = request.CreateResponse<ScbException[]>(HttpStatusCode.OK, scbexception);
            return response;
        });
    }

但是执行后出现此错误,我不明白为什么

{"Message":"The request is invalid.","MessageDetail":"The parameters dictionary contains a null entry for parameter 'ID' of non-nullable type 'System.Int32' for method 'System.Net.Http.HttpResponseMessage RevertExceptionById(System.Net.Http.HttpRequestMessage, Int32)' in 'Fintrak.Presentation.WebClient.API.ScbExceptionApiController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter."}

当我从exception.html的视图中运行此命令时

[[[[[[[[]]
可能的解决方案可能是:使用较低的ID,或使用string代替int作为ID。
c# asp.net angularjs
1个回答
1
投票
© www.soinside.com 2019 - 2024. All rights reserved.