I need to have an action parameter that has a datetime value? Is there a standard way to do this? I need to have something like:
mysite/Controller/Action/2
I thought I'd share what works for me in MVC5 for anyone that comes looking for a similar answer.
My Controller Signature looks like this:
public ActionResult Index(DateTime? EventDate, DateTime? EventTime)
{
}
My ActionLink looks like this in Razor:
@Url.Action("Index", "Book", new { EventDate = apptTime, EventTime = apptTime})
This gives a URL like this:
Book?EventDate=01%2F20%2F2016%2014%3A15%3A00&EventTime=01%2F20%2F2016%2014%3A15%3A00
Which encodes the date and time as it should.