How do I got about allowing my application to accept more that just ID in controller functions? Here's an example. If I write this function
public IHttpActionResult GetBadge(string id) { var badge = GetAllBadges().FirstOrDefault(b => b.slug == id); if (badge == null) { return NotFound(); } return Ok(badge); }
It works just great browsing to myapplication/api/badge/badge-name
However, if I change that to
public IHttpActionResult GetBadge(string slug) { var badge = GetAllBadges().FirstOrDefault(b => b.slug == slug); if (badge == null) { return NotFound(); } return Ok(badge); }
When I browse to the same page it returns all the data. I put a break point on that function, and it never even gets hit. How can I make it so I don't always have to name that argument id? I started this as a web forms empty project, and then checked web API, if that helps any.