我有一个 WebApi Get 操作
public HttpResponseMessage Get()
{
try
{
var queryValue = Request.RequestUri.ParseQueryString();
if (queryValue.Count == 0)
{
return Request.CreateResponse(HttpStatusCode.BadRequest, "Query String Filters Required");
}
我用这个网址打电话
api/funds?FundProductGroupCT=favourite&pagesize=10&startindex=8
RequestUri 始终剥离查询字符串。
这是我的 global.asax
GlobalConfiguration.Configuration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = System.Web.Http.RouteParameter.Optional }
);
System.Web.Http.GlobalConfiguration.Configuration.Routes.MapHttpRoute
("default", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = System.Web.Http.RouteParameter.Optional });