如何在web api请求中接收额外的参数

时间:2015-11-04 10:51:16

标签: asp.net-web-api httprequest request-headers

我正在写一个web api调用,除了请求参数之外,我还需要接收额外的参数,例如语言,deviceId等,这是最好的方法吗?

[GET("abc/{type}"), HttpGet]    
public HttpResponseMessage GetValues(int type, int page = 1)
{ 
int totalPages = 0; 
var d= Getvalues2(type, Settings.PageSize, page, out totalPages); 
if (d == null) { return NotFound();} 
return Ok(d)

1 个答案:

答案 0 :(得分:0)

也许这篇帖子有帮助: https://weblog.west-wind.com/posts/2012/May/08/Passing-multiple-POST-parameters-to-Web-API-Controller-Methods

使用HTTP POST,而JObject接收额外的参数。