zoukankan      html  css  js  c++  java
  • Can't bind multiple parameters ('header' and 'parameters') to the request's content.

    2019-01-23 15:46:29.012+08:00 ERROR [6]:
    System.InvalidOperationException: Can't bind multiple parameters ('header' and 'parameters') to the request's content.
    at System.Web.Http.Controllers.HttpActionBinding.ExecuteBindingAsync(HttpActionContext actionContext, CancellationToken cancellationToken)
    at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
    at LISA.WebApi.Chile.Helper.CustomMessageHandler.<SendAsync>d__3.MoveNext() in C:Usersclusource eposEdenredLISA_6.0.0.0LISA.CMS.ChileLISA.WebApi.ChileHelperCustomMessageHandler.cs:line 50
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at System.Web.Http.HttpServer.<SendAsync>d__24.MoveNext()

    出现这个错误的原因是,我的controller/action。

    action对应的方法,需要2个参数。但是post的时候,request body是一个json字符串。

    在目前不做parameter binding的情况下,直接将2个参数更改为1个参数JObject obj。

    然后在方法内部,对json字符串进行解析。

    dynamic json = obj;
    RedemptionInformationRequest parameters =
    JsonConverter.DeSerializer<RedemptionInformationRequest>(json.parameters.ToString());

    {
    "header": {
    "SecurityHash": "e1e7b4f072cfd5856a27a31640d5890bf3ccc5af7b5db810fc5e5906ee9f02bd"
    },
    "parameters": [
    {
    "TransactionId": "6117",
    "Result": "Accredited"
    },
    {
    "TransactionId": "6118",
    "Result": "Accepted"
    },
    {
    "TransactionId": "6119",
    "Result": "Error"
    }
    ]
    }

    json的数组是用[]表示的

  • 相关阅读:
    ExtJS的定时任务(转)
    Web开发系列–GIS(转)
    Windows Mobile 6.0模拟器的浏览器中不能访问本机网址
    JS定时保存表单数据(UserData 行为)
    查询Sqlserver数据库死锁的一个存储过程(转)
    ExtJS4.0在IE9中出现了SCRIPT5007: 无法获取属性“flex”的值
    Microsoft Device Emulator 模拟器菜单 中文
    错误:网站辅助进程已被 IIS 终止(Debug 时是不是弹出)
    集成验证时IE采用Kerberos 还是NTLM验证方式?(摘抄)
    SQLServer 2005死锁终极大法(自动杀) 转
  • 原文地址:https://www.cnblogs.com/chucklu/p/10309555.html
Copyright © 2011-2022 走看看