MVC route segment with a question mark?

In this article by Sam Shaffron, he mentions that Qaru has a route that looks like this:

questions/{id}/{title?} 

This is a missprint? What does this question mark do?

+5
source share
2 answers

From http://maproutes.codeplex.com/ :

[Url("store/{category?}")]
public ActionResult Products(string category)
{
    return View();
}

'?' A sign at the end of the parameter {category?}indicates that it is optional. UrlParameter.Optionalwill be the default value for it.

+5
source

StackOverflow uses attribute-based routing , so I assume the question mark indicates that the route parameter is optional.

+1
source

All Articles