private RouteValueDictionary ExtractConstraints(string path, string method) { var rwDict = new RouteValueDictionary(); var dictionary = RouteParser.Matches(path).Cast <Match>() .Where(match => match.Success && match.Groups["constraint"].Success && match.Groups["route"].Success) .ToDictionary(match => match.Groups["route"].Value, match => match.Groups["constraint"].Value.TrimStart(':')); if (dictionary.Count > 0) { foreach (var constraint in dictionary) { rwDict.Add(constraint.Key, constraint.Value); } } rwDict.Add("method", ApiHttpMethodConstraint.GetInstance(method)); //Adding method Constraint return(rwDict); }