.net中MVC Webapi多參數調用控制器方法

http://blog.csdn.net/wulex/article/details/71545471app

 

路由.net

public static void Register(HttpConfiguration config)
{code

// Web API routes
config.MapHttpAttributeRoutes();orm

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "dzopen/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);xml

}blog

 

控制器  使用Get請求路由

 

 

[HttpGet]
public HttpResponseMessage querymemberbymobileno([FromUri] userinfo user)
{
// name = HttpUtility.UrlEncode(name);get

string resp = "";
var resps = new HttpResponseMessage(HttpStatusCode.OK);
resps.Content = new StringContent(resp, Encoding.UTF8, "application/xml");
return resps;string

}
[HttpGet]
public string Get(string id)
{
return "Value";
}it

}

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; } } }

相關文章
相關標籤/搜索