.net中MVC Webapi多参数调用控制器方法
http://blog.csdn.net/wulex/article/details/71545471
路由
public static void Register(HttpConfiguration config)
{
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "dzopen/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
控制器 使用Get请求
[HttpGet]
public HttpResponseMessage querymemberbymobileno([FromUri] userinfo user)
{
// name = HttpUtility.UrlEncode(name);
string resp = "";
var resps = new HttpResponseMessage(HttpStatusCode.OK);
resps.Content = new StringContent(resp, Encoding.UTF8, "application/xml");
return resps;
}
[HttpGet]
public string Get(string id)
{
return "Value";
}
}
public class userinfo
{
public string shop_card_id{get;set;}
public string mobile_no{get;set;}
public string category{get;set;}
public string method{get;set;}
public string format{get;set;}
public string v{get;set;}
public string app_key{get;set;}
public string sign{get;set;}
public string timestamp{get;set;}
public string sign_method { get; set; }
}
}