ASP.NET5 MVC 6 routing with optional parameter / default parameter value
<p>I'm building Restful style API in VS2015, C#, ASP.NET5 MVC6 stack and I having some trouble when it comes to routing.</p>

<p>I'm using attributes directly in controller:</p>

<pre><code>[HttpGet("machine/{machineId}-{cnt:int}")]
public IActionResult GetReportsByMachineId(string machineId, int cnt)
{
    var item = _reportRepository.GetReportsByMachineId(machineId, 0, cnt);
    if ((item == null) || (!item.Any()) )
    {
        return HttpNotFound();
    }
    return new ObjectResult(item);
}
</code></pre>

<p>and it works when I call <code>api/report/machine/[machineName]-5</code> - I receive <code>5</code> documents from the database.</p>

<p>But I would like to make <code>cnt</code> parameter optional with default value - so the call for <code>api/report/machine/[machineName]</code> would be valid.</p>

<p>Based on <a href="http://stephenwalther.com/archive/2015/02/07/asp-net-5-deep-dive-routing" rel="noreferrer">http://stephenwalther.com/archive/2015/02/07/asp-net-5-deep-dive-routing</a> I've tried so far:</p>

<p><code>[HttpGet("machine/{machineId}-{cnt:int=10}")]</code> - controller don't catch <code>api/machine/{machineName}</code> (I get welcome page code)</p>

<p><code>[HttpGet("machine/{machineId}-{cnt?}")]</code> - app wont start (I don't even get MVC welcome page)</p>

<p><code>[HttpGet("machine/{machineId}-{cnt:int?}")]</code> - app wont start (like above)</p>

<p>Any ideas?</p>

<p>Code for whole controller (I don't have any other routes specified):
<a href="http://pastebin.pl/view/11050284" rel="noreferrer">http://pastebin.pl/view/11050284</a></p>