如何在 Asp.Net Web API 中要求某些路由的查询字符串?
控制器:
public class AppleController : ApiController
{
public string Get() { return "hello"; }
public string GetString(string x) { return "hello " + x; }
}
public class BananaController : ApiController
{
public string Get() { return "goodbye"; }
public string GetInt(int y) { return "goodbye number " + y; }
}
想要的路线:
/apple --> AppleController --> Get()
/apple?x=foo --> AppleController --> Get(x)
/banana --> BananaController --> Get()
/banana?y=123 --> BananaController --> Get(y)