CustomRoute url

Nov 1, 2013 at 10:40 AM
Hi Max,

Thank you for the good work.
We dont like hard coded values in our application. So instead of using
CustomRoute("~car/information/{carId}") , Is there any other way I can represent the url?
Thank you for your help

Nov 1, 2013 at 2:17 PM
Edited Nov 1, 2013 at 2:18 PM
namespace MyApp.Car {

   public class InformationController : Controller {
      public ActionResult Information([FromRoute]int id) {
...asuming the root controller is something like MyApp.HomeController.
Apr 25, 2014 at 5:24 PM
As a follow on to this... How do we get routing to an ApiController at its root?

For example:

(which returns an unfiltered collection of entities)

You demonstrate above how to get at a unique item using:

(which returns single entity of id 123)

How do we map a root url?
Apr 25, 2014 at 5:46 PM
Nevermind, I just figured it out...

Decorating the Action method with [CustomRoute("")] did the trick.

This MvcCodeRouting framework has really been a great addition when writing RESTful Api's.

Thanks again for the good work.
Apr 25, 2014 at 6:05 PM
It's simpler than that, just create an action named Get. No need to use [CustomRoute].
Apr 25, 2014 at 7:42 PM
Even better - thanks!