mvc4中的WEBAPI,发现接收参数不是很方便,跟传统的request.querystring和request.form有很大区别,在网上搜了一大圈,各种方案都有,但不是太详细,于是跟踪Action中的变量,仔细查看,最后发现了解决方案,下面是代码:
1 public void Post([FromBody]string value) 2 { 3 HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];//获取传统context 4 HttpRequestBase request = context.Request;//定义传统request对象 5 string name = request.Form["name"]; 6 7 }