RouteAttribute
RouteAttribute is an ASP.NET Core attribute that associates a controller or action with a route template.
Pro ASP.NET Core 7, Tenth Edition
The Route attribute declares URL route information on an ASP.NET Core controller or action.
- How it is used
- Sets a web-service controller’s base URL for matching HTTP requests to actions.
- How deep it goes
- Explains controller-token substitution and composition with action routes, but does not detail routing internals.
- Examples
- Uses a ProductsController with GET routes for `/api/products` and `/api/products/{id}`.
- What you can do after
- Apply it via ASP.NET Core MVC to give a controller a base URL and distinguish GET endpoints.
Read how Pro ASP.NET Core 7, Tenth Edition explains RouteAttribute →
ASP.NET Core in Action, 3e
RouteAttribute is an ASP.NET Core attribute that associates a controller action with a route template.
- How it is used
- Maps explicit URL templates to web API controller actions and controls the URLs exposed by an API.
- How deep it goes
- Explains literal segments, parameters, multiple templates, controller prefixes, absolute routes, and HTTP-verb constraints.
- Examples
- Uses HomeController, CarController, appointment endpoints, multiple URLs, route parameters, and shared api/car prefixes.
- What you can do after
- Apply it via ASP.NET Core attributes to build explicit API URLs and constrain actions to required HTTP verbs.
Read how ASP.NET Core in Action, 3e explains RouteAttribute →
Building Web APIs with ASP.NET Core
A route attribute is an ASP.NET Core attribute that associates a controller or action with a route template.
- How it is used
- Configures controller and action URL patterns in an ASP.NET Core web API.
- How deep it goes
- Explains controller-level prefixes and route-template choices, while deferring broader API status-code conventions.
- Examples
- Uses SampleController routes for collection, identifier, and delete requests, plus SeedController’s [controller] route.
- What you can do after
- Configure controller URL patterns and combine them with HTTP verb attributes to expose API actions.
Read how Building Web APIs with ASP.NET Core explains RouteAttribute →
What to know first
- JSONJSON is a language-independent text-based data-interchange format that represents structured values using objects, arrays, strings, numbers, booleans, and null.
- xmlXML (Extensible Markup Language) is a text-based markup language for representing structured information using elements, attributes, and nested relationships.
Related concepts
- controllerconfigures · A controller is a software component that receives input or requests and coordinates other components or operations to produce a response or change application state.
- explicit routingused by · Explicit routing is a routing approach in which each endpoint is assigned a specific URL pattern directly, often through route templates or attributes.
- route templateconfigures · A route template is a URL path pattern, often containing parameters, that an application uses to match requests to handlers or operations.
- routingused by · Routing is the process of directing an item, request, or task to a destination or processing path according to relevant rules or characteristics.
- web API action methodconfigures · A web API action method is a controller method associated with a matched HTTP request that processes it and produces a response.
Questions about RouteAttribute
What is RouteAttribute?
RouteAttribute is an ASP.NET Core attribute that associates a controller or action with a route template.
Which Manning books explain RouteAttribute?
Pro ASP.NET Core 7, Tenth Edition, ASP.NET Core in Action, 3e and Building Web APIs with ASP.NET Core.
What should I know before learning RouteAttribute?
Manning books that teach RouteAttribute usually introduce JSON and xml first.
What is RouteAttribute also called?
RouteAttribute is also called route attribute.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


