- I would recommend AttributeRouting, I wrote it and use it every day.
- To start up, simply decorate an action with a GET attribute. Nuget does the rest.
- Nuget yes.
I like URLs.
I like seeing them right above the code they map to.
[GET("some/url")]
public ActionResult HotDamn()
When you do this, you can ctrl+F "some/url" and go right your action method, which is pretty handy. If you change your action name or move it somewhere else, the route stays with it and is unchanged.
[GET("some/url"]
public ActionResult HotDarnCauseCussingIsBad()
If you want to change URLs and still respond to the legacy URL, just add another attribute above the old one and mark it as the new one by setting Order = 1:
[GET("better/url", Order = 1)]
[GET("some/url")] // order defaults to int.MaxValue
public ActionResult BetterMethodName()
If you want to get restful, and go all the way with HTTP method overrides and support GET/POST/PUT/DELETE, you just go right on with your bad self:
[GET("")]
public ActionResult Index()
[POST("")]
public ActionResult Create()
[PUT("{id}")]
public ActionResult Update()
[DELETE("{id}")]
public ActionResult Delete()
I use this lib all the time, and made it so I could. I have been using it for a year and a half and I never ever have trouble with routing or finding where things go or wondering why route A got matched instead of route B. It's super easy to use, has quite a few configuration options, and makes routing 100x simpler (in my opinion).
Whatever you choose, I definitely recommend at least trying attribute based routing, whether AR or something else. May not be everybody's cup-o-tea, but I absolutely love it.