Routing based on query string parameter name

前端 未结 4 528
Happy的楠姐
Happy的楠姐 2020-12-08 10:06

I\'m trying to configure routing in my MVC4 WebAPI project.

I want to be able to search for products based on their name or their type like so:

/api/pr

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 11:04

    Are you sure that the controllers are ok? I mean, the name of the params.

        public string GetProductsByName(string name)
        {
            return "Requested name: " + name;
        }
    
        public string GetProductsByType(string type)
        {
            return "Requested type: " + type;
        }
    

提交回复
热议问题