Skip to content
This repository

Define your routes using attributes on action methods in ASP.NET MVC and Web API.

README.textile

Please refer to attributerouting.net for documentation.

If you encounter any issues using this library, please log them in the issue tracker. Thanks.

Changelog

3.5.6

  • #219 – BUG FIX: with handling of querystring optionals.
  • Now applying default constraints to matching query string params.

3.5.5

  • #218 – BUG FIX: fixed handling of querystring default values.

3.5.4

  • #217 – Improved perf of ObjectExtensions.SafeGet. Thanks youssefm!
  • BUG FIX: fixed bug in handling of default values with querystring params.

3.5.3

  • #216 – testing optional constraint for mvc against null/empty in addition to UrlParameter.Optional.
  • #211 – parsing defaults from complete url, including areas and prefixes.

3.5.2

  • #214 – BUG FIX: fixed thread safety issues encountered when dealing with query string route constraints."

3.5.1

  • #199 – when applying inbound http method constraint, now checking the unvalidated form/query collection.
  • #206 – changed the name of the app start files to prevent ns conflicts.

3.5

  • #191 – Enabled in-memory hosting of web-hosted web api routes.
  • Various perf enhancements and code reorganization.

3.4.2

  • #192 – BUG FIX: Optional parameters weren’t working in asp.net web api action urls.
  • #183 – Bllowing route conventions to be inherited from base controllers.
  • #182 – Inlined scripts required by routes.axd
  • #180 – New route constraint EnumValueConstraint for matching enums by value.

3.4.1

  • #175 – fixed bug in getting the default area name for a controller.

3.4

  • #124 – Now supporting custom IRouteHandler in web-host scenario. Also supporting custom HttpMessageHandler for Web API.
  • #146 – BUG FIX: AR’s custom http method constraint was interfering with IHostBufferPolicySelector, because it was checking for the incoming http method too early in the pipeline.
  • #155 – Can now specify multiple route prefixes on a controller. Every action will get each prefix. You can control precedence of the prefixes by using the Precedence property.
  • #156 – Added action method to route data tokens.
  • #161 – BUG FIX: Url generation was bonking for routes that included a querystring route param constraint.
  • #162 – Modified design of route convention attribute, adding facility for specifying an area attribute for a controller. Also opened up {controller} and {action} url params as special params that will be replaced with controller and action values from the defaults collection for the route.
  • #164 – Added default ctors to RoutePrefixAttribute, RouteAreaAttribute, and the AttributeRouting.Web.Mvc route attributes. These default ctors will use a convention to get their URL components: RoutePrefix – will use the controller name; RouteArea – will use the last section of the controller’s namespace; and the route attributes – will use the action name by default.
  • #165 – Added two flags to the route attributes: IgnoreRoutePrefix and IgnoreAreaUrl. These flags control whether to prepend route prefixes or area urls to the generated route url.

3.3

  • #153 – fixed bad parsing of regex route constraint patterns that use a comma.
  • #132 – basic support for constraints in the querystring.
  • #152 – added support for specifying that query param simply exists, without constraining by anything else.
  • #154 – added support for querystring constraint description in routes.axd.
  • #159 – added compiled regex in RegexRouteConstraint to improve performance.
  • #150 – changed IAttributeRouteFactory method to return multiple routes.

3.2

  • #142 – Now accepting inline route constraints in the area url part of routes."

3.1.5

  • #140 – Renamed AttributeFactory in configuration object to AttributeRouteFactory.

3.1.4

  • #140 – Allowed setting various factories in attribute routing configuration objects.
  • #139 – Changed to Use OfType instead of “Where is Cast”.

3.1.3

  • #128 – Fixed issue with route cast in LogRoutesHandler; was assuming all routes were of type Route.

3.1.2

  • #128 – fixed null ref in self-host projects due to default route name builder.
  • Simplified the init of AR in self-hosted APIs.

3.1.1

  • #125 – Covered regression edge-case when using 0 to specify route order, precedence, site precedence. Now can start with zero.
  • Added ActionPrecedence to replace Order and ControllerPrecedence to replace Precedence properties; help clarify intent.
  • For more info, see Controlling Route Precedence

3.1.0

  • #121 – added facility for specifying the order of controller route registration via the config api.
  • #121 – added facility for specifying the last routes in the site using the SitePrecedence property.
  • #121 – added facility for specifying the last routes in a controller using the Precedence property.
  • #121 – added facility for specifying the last routes on an action using the Order property.
  • For more info, see Controlling Route Precedence

3.0.0.0

  • See Upgrading to v3
  • #122 – WebHost package now uses HttpRouteCollection to register routes, as it should!
  • #109 – nuked AddRemainingScannedRoutes method ont he config object; was obsolete for some time now.
  • #109 – removed old ctor method of specifying verbs in RouteAttribute from a bitwise or operation to a param array of HttpVerbs.
  • #109 – removed support for specifying optional params with a leading question mark.
  • #109 – removed support for legacy inline regex route constraint syntax.
  • #109 – nuked RouteDefaultAttribute and RouteConstraintAttribute support. Superceded by inline expression.

2.5.3

  • #120 – fixed bug caused by OData-style urls like “devices(ua={id})”; the url wasn’t being detokenized properly.

2.5.2

  • #118 – added dependencies to web api projects in web and self host AR projects.
  • #79 – added MVC 4 t4 templates for visual studio add controller tooling which generates controllers that use AR. Also released new nuget package for sucking those templates into a project.
  • #116 – now supporting VB.NET projects! App_Start file drop and CodeTemplates drop will add cs/vb specific files, depending on the type of the host project.

2.5.1

  • #111 – route prefixes now honor inline url constraints.

2.5.0.0

  • #106 – improved the logic used to auto-generate route names: no longer will two routes be added with the same; added configuration hook for defining your own route convention. Docs here

2.5.0-pre

  • #90 – implemented workaround for runtime exception when running agains Web API nightlies. Will flip switch to 2.5.0.0 whenthe Web API RTM drops.
  • #105 – can now use SitePrecedence property on the route attributes to set the precedence of a single URL in the route table.
  • Revised nuget package structure to help the various packages paly nice with shared assemblies (ASP.NET MVC and Web API especially).
  • #104 – much improved routes.axd, allowing direct navigation to static urls and giving you a handy url builder to jump to dynamic urls.

2.4.3

  • Updated Web API RC integration, seems to help with #86.

2.4.2

  • #99 – Fixed bug in subdomain routing due to not being able to parse a host from the current request.

2.4.1

  • #73 – updated MVC 2 reference to MVC 3

v2.4

  • #84 – fixed routing to asynchronous actions.

v2.3

  • #81 – Updated Web API references from Beta to RC. Fixed a few compilation erros due to switch.

v2.2.3

  • Fixed bug in RestfulHttpMethodContraint for web projects. Was not honoring http method overrides in request headers, forms, or query collections.
  • Implemented one of Sam Saffron’s performance enhancements for speeding up route table lookups.
  • #82 – added OPTIONS verb to GET/PUT/POST/DELETE attributes in web API attributes.
  • Removed references to MVC2, now using MVC3.

v2.2.2

  • #71 – fixed bug in regex pattern matching when multiple url parameters existed for a single url segment.

v2.2.1

  • #65 – fixed bug introduced in v2.* that arises when using the RouteAttribute on actions without specifying a verb.

v2.2

v2.1.1

  • #63 – BREAKING CHANGE! Fixed issue with ambigous routes in MVC controllers. All prior versions worked from AttributeRouting.VERBAttribute, and these have moved into MVC and Web API specific versions to handle disambiguation: AttributeRouting.Web.Mvc.VERBAttribute and AttributeRouting.Web.Http.VERBAttribute.

v2.1

  • #60 – can now override global configuration settings for UseLowercaseRoutes, PreserveCaseForUrlParameters, and AppendTrailingSlash via similarly named properties on the route attributes (GET, POST, PUT, DELETE, and Route).

v2.0

  • #57, #52 Added support for Web API, both Web-hosted and Self-hosted
    – Added new Nuget packages, AttributeRouting.WebApi and AttributeRouting.WebApi.Hosted

v1.7

  • #53 – added config setting for resolving the current UI culture name when constraining inbound requests.
  • #56 – Added Configuration to inherit actions defined on a base controller
  • #54 – fixed null ref exception when hitting routes.axd

v1.6

  • Can now choose to preserve the case for url parameters
  • Added logic and config option to constrain routes by the culture name of the current thread. The route is considered when: 1) no translations exist for the route; 2) it is translated for the current UI culture; 3) it is translated for the neutral culture when no translation exists for the specific culture. This constraint logic follow the logic used when choosing the translation to use when generating outbound routes.

v1.5.4426

  • Made modification to configuration of route translation providers. Used to be config.TranslationProvider = …, now it is config.AddTranslationProvider(). This allows adding multiple providers. THIS IS A BREAKING CHANGE. Please see the wiki page regarding [[Localization]].

v1.5

  • Added localization support via TranslationProvider configuration option.
  • Added support for mapping areas to static subdomains.

v1.4

  • Fixed logic in getting values from form and querystring collections, so that no errors are thrown during “potentially dangerous requests” when System.Web.Helpers is available.
  • Added ability to append trailing slash to URL path of outgoing URLs.
  • Support custom route handler factory.

v1.3.2

  • Removed reference to System.Web.WebPages in AR. Now, when checking for form or query values for the http method override, AR is dynamically checking for System.Web.WebPages, and if found, will use the Unvalidated collection rather than request.form or request.querystring.

v1.3.1

  • Fixed bug I introduced when trying to exclude route params from lowercase route generation. Will try again later.

v1.3

  • Issue 18 – allowed route params case to be preserved while lowercasing the area, controller, and action.
  • Identify controllers that do not inherit from Controller
  • Add strongly typed way to specify allowed HTTP methods for RouteAttribute

v1.2.1

  • Issue 24 – fixed null reference in GetHttpMethod extension when inspecting routes in unit tests (ie: mocked http contexts).

v1.2

  • Used System.Web.WebHelpers to sniff the form and querystring collections hanging off the request for an http method override without triggering request xss validation.
  • Marked configuration object’s AddRemainingScannedRoutes method as obsolete beacause it is … obsolete.

v1.1

  • Fixed bug that occured when building route urls that have areas or prefixes that start with the route url, even when it is only a partial match.
  • Fixed reflection logic for finding action methods. Used to restrict to public instance methods that returned type assignable to ActionMethod; now simply returns public instance methods, in line with the true definition of an action method in MVC.

v1.0

  • Modified the base RouteAttribute to allow it to work without an http method constraint, so that an action can respond to any verb.
  • Added ability to specify optional parameter token (?) at either beginning or end of url param.
  • Added ability to specify route defaults inline with the url parameter.
  • Added ability to specify regex route constraints inline with the url parameter.

v0.8

  • Fixed bug in base route attribute that disallowed URLs like Somewhere/{*pathInfo}, barfing on the asterisk.

v0.7.4119

  • Added HEAD constraint to GET attribute so that all GET routes will respond to HEAD requests as well.
  • Fixed bug when testing whether a route starts with an area url applicable to the route. Previously it was comparing against the area name, which was recently made overridable, and part of this logic was not updated.
  • Fleshed out XML doc comments.
  • Fixed bug in ordering of routes for an action when using a RouteConvention.
  • Added T4 CodeTemplates for controllers and views to swap with the defaults provided in MVC projects.
  • Fixed bug in applying global route constraints — when more than one url parameter matches the specified regex, only the first one matched has the constraint applied. Corrected this so that each matched url parameter has the constraint applied.

v0.6.4033

  • Added IsAbsoluteUrl property to the RouteAttributes, which prevents the RouteAreaAttribute and RoutePrefixAttribute from prefixing the URL for a route. This can be handy for legacy URL support.
  • Added Precedence property to the RouteAtrributes, which allows you to specify the precedence of a route among all the routes defined for the controller.
  • New and improved output from the LogRoutesHandler.
  • New RouteConventionAttribute, which allows you to create your own convention-based route generator for actions within a controller. There is also a RestfulRouteConventionAttribute, which automatically creates RESTful routes for standard actions in your controller.
Something went wrong with that request. Please try again.