I\'ve got a problem with regular expressions in Route attribute. I\'d like to create RESTful API, where you can specify start date and end date in URL to filter results. Wha
For nullable second parameter, write your route template as
[Route("api/recommendations/date/{startDate:datetime:regex(\\d{2}-\\d{2}-\\d{4})}/{endDate:datetime:regex(\\d{2}-\\d{2}-\\d{4})?}")]
And you should provide with a default value for nullable parameter
public IEnumerable<Recommendation> GetRecommendationByDate(DateTime startDate, DateTime? endDate = null)
For slashes, slash is used to separate url segments, which means one single segment can't contain slash unless they are encoded.