AttributeRouting for MVC

Posted by

AttributeRouting is a fantastic open source Nuget package which allows you to specify routes using attributes on your MVC controllers and actions. We use it in all of our MVC projects at work and I highly recommended it, saves you having to map all y.

Attribute Routing

The QuickStart Guide can be found here.

Main reasons to use AttributeRouting

•Decorate your actions with GET, POST, PUT, DELETE, and verb agnostic attributes.
•Map multiple routes to a single action, ordering them with an Order property.
•Specify route defaults and constraints inline and also using attributes.
•Specify optional params inline with a token before or after the parameter name.
•Specify the route name for supporting named routes.
•Define MVC areas on a controller or base controller.
•Group or nest your routes together using route prefixes applied to a controller or base controller.
•Support legacy urls.
•Set the precedence of routes among the routes defined for an action, within a controller, and among controllers and base controllers.
•Generate lowercase outbound urls automatically.
•Define your own custom route conventions and apply them on a controller to generate the routes for actions within the controller without boilerplate attributes (think RESTful style).
•Debug your routes using a supplied HttpHandler.

Go check it out you wont be disappointed.


  1. Amazing package. What i really liked is that you have control over your routes easily and in a pretty good way. Can’t wait to try it.

  2. I like AttributeRouting but can’t seem to get unit testing to work for it. Is this something you’ve played around with?

      1. Hi, thanks for your help.

        I cannot seem to populate the route collection from a test project, at most i only end up with the default ignoreroute {resource}.axd.

        I have added a testmethod with the following :-

        var routes = new RouteCollection();


        routes.MapAttributeRoutes(x => x.ScanAssemblyOf());

Leave a Reply to Haythem Tlili Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s