string
代替int
作为ID。当我从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的视图中运行此命令时
string
代替int
作为ID。