How do I create a truly multi-purpose endpoint using WebAPI 2 with optional parameters? <p>Thanks for looking.</p> <p>I am attempting to make the following code work:</p> <pre><code>[RoutePrefix("api/user")] public class UserController : ApiController { [AllowAnonymous] [Route("{email}")] public IHttpActionResult Get(string email = null) { if (!string.IsNullOrEmpty(email)) { return Json(someUserProfileObject); } return Json(someListOfUserProfiles); } } </code></pre> <p>Whenever I try and access /api/user/some@email.com, I get a <code>405</code>.</p> <h1>SOLVED!</h1> <p>Please see solution in my answer below.</p>