简体   繁体   English

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

[英]Getting “The parameters dictionary contains a null entry for parameter 'ID' of non-nullable type 'System.Int32' for method X” in C#

When I run this command from my view in exceptions.html当我在exceptions.html中从我的视图中运行此命令时。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>

and in my controller file exception.js , this is the method I call在我的 controller 文件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);
   }

which generates this URL when clicked on, even after setting a breakpoint on the apicontroller file, I get this error:单击它会生成此 URL,即使在 apicontroller 文件上设置断点后,我也会收到此错误:

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

and I have a method in my Api Controller { ScbExceptionApiController } that receives the function and method here...我在我的 Api Controller { ScbExceptionApiController } 中有一个方法,它接收 function 和这里的方法......

    [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;
        });
    }

but after execution I get this error, and I don't understand why但执行后我得到这个错误,我不明白为什么

{"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."}

RevertExceptionById(HttpRequestMessage request, int ID) is expecting ID as an int , which is a 32-bit integer. RevertExceptionById(HttpRequestMessage request, int ID)期望IDint ,即 32 位 integer。

The max value of a 32-bit integer is 2147483647 . 32 位 integer 的最大值2147483647 You're passing 10000011943 as the ID, which is exceeding this max value.您将10000011943作为 ID 传递,它超过了这个最大值。

I suspect this is the reason the parameter binding for ID is failing with the given exception.我怀疑这是ID的参数绑定因给定异常而失败的原因。

Possible solutions could be: use lower ids, or use string instead of int for the ID.可能的解决方案可能是:使用较低的 id,或使用string而不是int作为 ID。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 参数字典包含不可为空类型“System.Int32”的参数“id”的 null 条目。 - The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' . . 参数字典包含非空类型&#39;System.Int32&#39;的参数&#39;id&#39;的空条目 - The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' 参数字典包含非空类型&#39;System.Int32&#39;的参数&#39;_id&#39;的空条目 - The parameters dictionary contains a null entry for parameter '_id' of non-nullable type 'System.Int32' 参数字典包含一个 null 条目,用于不可为空类型“System.Int32”的参数“id” - The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' 参数字典包含用于方法的非空类型&#39;System.Int32&#39;的参数&#39;userId&#39;的空条目 - The parameters dictionary contains a null entry for parameter 'userId' of non-nullable type 'System.Int32' for method 参数字典包含用于方法的非空类型&#39;System.Int32&#39;的参数&#39;foo&#39;的空条目 - The parameters dictionary contains a null entry for parameter 'foo' of non-nullable type 'System.Int32' for method Create(Int32) 参数字典包含不可为空类型“System.Int32”的参数“id”的空条目 - Create(Int32) the parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' 参数字典包含非空类型为&#39;System.Int32&#39;的参数的空条目 - The parameters dictionary contains a null entry for parameter of non-nullable type 'System.Int32' 参数字典包含非空类型&#39;System.Int32的参数&#39;restaurantId&#39;的空条目 - The parameters dictionary contains a null entry for parameter 'restaurantId' of non-nullable type 'System.Int32 参数字典包含非可空类型&#39;System.Int32&#39;的参数&#39;idd&#39;的空条目 - The parameters dictionary contains a null entry for parameter 'idd' of non-nullable type 'System.Int32'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM