asp-route-date="@{ DateTimeOffset.Parse(date); }"
Should that work? Can't find any info. Currently that somehow give me pure date
variable value, f.e. - ...?date=01%2F02%2F2020+4%3A49+PM
asp-route-date="@{ DateTimeOffset.Parse(date); }"
Should that work? Can't find any info. Currently that somehow give me pure date
variable value, f.e. - ...?date=01%2F02%2F2020+4%3A49+PM
Use Razor expressions instead Razor code blocks so that the value will be rendered in the resulting HTML, e.g.:
Razor:
<a asp-action="CheckDate" asp-route-date="@DateTimeOffset.Parse(date)">check</a>
Controller:
public ActionResult CheckDate(DateTimeOffset date)
{
// ...
}
The query string in your example seems fine, as the DateTimeOffset
object needs to be encoded to be passed to the controller. For alternative formats and further information see How do I pass a datetime value as a URI parameter in asp.net mvc?.