I have this route:
routes.MapRoute(
"PlaceDetails",
"{controller}/{action}/{id}",
new { controller = "Place", action = "Details", id = UrlParameter.Optional }
);
This routes this fine: mysite.com/place/details/123
Making Id 123 available to the details action of the place controller - which can then lookup place '123'.
However - this URL is also passed to the controller: mysite.com/place/details/
I want this to return HttpNotFound
- but it sends a null Id to the controller - and requires me to handle that.
It seems neater if the route itself achieves this rather than needing unseemly null checks in the controller itself.
I have found nothing in Google about this specific issue.
How can I do this?