September 23rd, 2013

Attribute Routing changes for ASP.NET Web Stack shipped in VS2013 RC

For the VS2013 Preview release, we published two articles about Attribute Routing for Web API 2:

· http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2

· http://www.asp.net/web-api/overview/web-api-routing-and-actions/create-a-rest-api-with-attribute-routing

The VS2013 RC release includes more changes and features for attribute routing:

1. Explicitly declare a route template on an action

In RC, if attribute routing is enabled, you must explicitly declare the attribute for the desired actions. In Preview, you don’t have to.

clip_image001

2. Added support for overriding RoutePrefix attribute.

In the following controller code, the action to ‘get all the books’ has a route template like “~/”. This overrides the RoutePrefix for this action and a user can reach this action by requesting GET on http://hostname:hostport/ .

clip_image002

3. Support for multiple RoutePrefix attributes on a controller has been removed. Only one RoutePrefix attribute can be applied to a controller.

4. The Order property is removed from the RoutePrefix attribute.

We’ll be changing even more for RTM — stay tuned. For information about what’s planned, see the attribute routing design specification on the CodePlex site.

Author

0 comments

Discussion are closed.