[Solved] Parameter with hyphen in Web API 2

try this for url …./api/books?author-id=3&genre-id=5 . It works for all net versions [HttpGet] public async Task<IHttpActionResult> GetBooks() { var parameters = GetBooksParameters(HttpContext); // … } [NonAction] private BooksParameters GetBooksParameters(HttpContext httpContext) { var parameters = new BooksParameters(); var queryString = httpContext.Request.QueryString.Value; foreach (string item in queryString.Split(‘&’)) { string[] parts = item.Replace(“?”, “”).Split(‘=’); switch (parts[0]) { case … Read more