ASP.NET Web Api 2 - Attribute Based Routing - How do I force a parameter to query string only?
问题 I am working on a Web Api 2 project and I am using attribute based routing. Here is a sample route: [Route("{id:int}", Name = "GetEmployeeById")] [HttpGet] public IHttpActionResult GetEmployee(int id) { ... } This works with the following URLs: ://host/employee/12345 ://host/employee?id=12345 What I would prefer is that the first form (the parameter in the URI), would not be allowed, and only the second form (query string) would work. What I've Tried Mostly, I've tried searching the web for a