文章:webapi设置一个Action同时支持get和post请求

这篇文章,有提供方法。参数前加上[FromUri]

[AcceptVerbs("GET", "POST")]
public HttpResponseMessage Http([FromUri]ProxyHttpParam getParam, ProxyHttpParam postParam)
{
    var res = new HttpResponseMessage(HttpStatusCode.OK);
    return res;
}

 

个人思考是因为路由的严格限制导致的问题。mvc中曾经碰到这种问题

临时方法是:干掉方法的参数,在方法内部进行参数接收,Request["data"];

 

相关文章:

  • 2022-12-23
  • 2021-10-04
  • 2021-05-29
猜你喜欢
  • 2021-11-12
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案