Commit Graph

32 Commits

Author SHA1 Message Date
James Newton-King 40959a97e7
Fix link generation of routes with default values (#8616) 2018-10-23 16:10:43 +13:00
James Newton-King 94101a9cde
Add PageRouteTransformerConvention (#8541) 2018-10-04 17:34:26 +13:00
James Newton-King 7854d65c11
Support page parameter in attribute route (#8530) 2018-10-04 14:39:40 +13:00
Ryan Nowak cb1393cbb1 Adding functional tests for LinkGenerator 2018-09-29 20:34:48 -07:00
James Newton-King 8791f9ad0d
Change test parameter transformer to slugify values (#8453) 2018-09-15 09:14:48 +12:00
James Newton-King dfae9c208a
Add IParameterTransformer support (#8329) 2018-09-12 21:46:41 +12:00
James Newton-King 927e7c8bfc
Support route data tokens with Endpoint Routing (#8360) 2018-08-30 15:14:34 +12:00
James Newton-King cbe1526763
React to routing changes (#8303) 2018-08-22 17:15:09 +12:00
James Newton-King c08504b08a
MVC startup experience (#8131) 2018-07-25 14:30:51 +12:00
James Newton-King 183ecd85d6
Fix MVC integration with UseEndpoint (#8047) 2018-07-11 11:47:33 +12:00
jacalvar f0732e9e21 [Fixes #5038] HTTP Verbs mapping error GET and DELETE
When an action contained an attribute derived from HttpMethodAttribute,
doesn't specify an attribute route and there is also another attribute
extending HttpMethodAttribute that has a route defined on it; we ignored
the HttpMethodAttribute attribute without a defined route when building
the set of action selectors for the method.

This caused the resulting action to be unbounded and to accept requests
for other verbs not associated with it. The root cause of the problem was
that attributes override equality and do a field by field comparison but
ignore fields in the base classes of the type, so if an attribute is part
of a class hierarchy (like Http*Attributes) there might be two different
attributes that get considered equal.

The fix for the problem has been to change using Contains on a couple of
collections (that uses the equals method on the underlying object) and
check for the existence of the attribute on the collection directly by
using reference equality.
2016-08-01 12:49:23 -07:00
Ryan Nowak 171f4452e3 Repair failing functional test
I recently consolidated some code in routing that made the behavior for
attribute routes and conventional routes more consistent. So now, a
catch-all will add a null value to the RVD if it doesn't capture any text,
but will NOT trounce an existing value in the RVD.

This test depended on the behavior where attribute routes didn't ever add
a null value for a catch-all. The fix is to just add a default to the
catch-all.
2016-04-11 12:07:51 -07:00
N. Taylor Mullen 3be7fbdf9f Rename AspNet 5 file contents.
See https://github.com/aspnet/Announcements/issues/144 for more information.
2016-01-22 12:18:33 -08:00
Ajay Bhargav Baaskaran 43eb621d19 [Fixes #2743] Removed ErrorReporterMiddleware in some places 2015-12-16 14:39:35 -08:00
Ajay Bhargav Baaskaran 232b27ad5d [Fixes #3430] Removed RouteKeyHandling.CatchAll 2015-12-16 11:57:22 -08:00
Ajay Bhargav Baaskaran 4fbaea2463 [Fixes #2931] AttributeRoute does not replace existing route values with null 2015-08-28 11:11:03 -07:00
N. Taylor Mullen 64e726d2b2 Update LICENSE.txt and license header on files. 2015-05-01 13:55:25 -07:00
Kirthi Krishnamraju 9d2b1822d9 Fix for #819 : Attribute Routing: Resolve Name + Token Replacement 2015-04-22 11:47:23 -07:00
Doug Bunting 7eb106676c Add missing license headers
- #EngineeringDay
- license present but incorrect in just a few files
- skip generated files such as Resources.Designer.cs and files under
  test\Microsoft.AspNet.Mvc.Razor.Host.Test\TestFiles\Output
2014-11-20 22:54:05 -08:00
Doug Bunting 315908af5f Apply VS' FormatDocument and RemoveAndSort to all *.cs files
- #EngineeringDay
- VS does not yet format auto-properties nicely; reverted what it did

Also revert changes under
- test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles
2014-11-20 21:15:46 -08:00
Ryan Nowak ed8ba5ae9c Fix for #1194 - Error using [HttpPost] and [Route] together
This change enables some compatibility scenarios with MVC 5 by expanding
the set of legal ways to configure attribute routing. Most promiently, the
following example is now legal:

[HttpPost]
[Route("Products")]
public void MyAction() { }

This will define a single action that accepts POST on route "Products".

See the comments in #1194 for a more detailed description of what changed
with more examples.
2014-11-19 15:52:20 -08:00
jacalvar 775a780f49 [Fixes #739] Attribute Routing: Multiple routes per-action
1. Support multiple [Http*] attributes on an action.
2. Support multiple [Route] attributes on a controller and on an action.
3. Support creating multiple attribute routes using [AcceptVerbs("...", Route = "...")]
4. Detect attribute routed actions during action discovery and return one action per [Http*],
   [Route] or [AcceptVerbs] attribute found on the method when there is at least one valid attribute route.
5. Merge all the HTTP methods of [Http*] and [AcceptVerbs] attributes in a method during
   action discovery when there are no valid attribute routes defined on the action.
6. Build one action descriptor per controller [Route] + action [Http*], [AcceptVerbs]
   or [Route] combination in an action.
7. Disallow the use of attributes that do not implement IActionHttpMethodProvider and
   IRouteTemplateProvider simultaneously in methods that define attribute routed
   actions and throw an exception during startup.
8. Disallow mixing attribute routed and non attribute routed actions on the same method
   and throw an exception during startup.
2014-09-12 14:43:19 -07:00
jacalvar cde1a95d49 [Fixes #900] Use [Route(...)] on action methods to specify an attribute route that allows all verbs.
1. Changed attribute usage on RouteAttribute.
2. Added a test on action discovery to ensure that actions with [Route] get discovered as
   attribute routed actions.
3. Added a test on reflected action descriptor provider to ensure that an action with [Route] on
   the controller and [Route] on the action results in an action that allows any Http method.
2014-09-10 10:11:42 -07:00
jacalvar ccc20a38c1 [Fixes #734] Attribute Routing: Implement Name
1. Added support for Name in attribute routing. Name can be defined using [RouteAttribute]
and the different Http*Attributes, for example [HttpGet].

2. Names defined on actions always override names defined on the controller.

3. Actions with a non empty template don't inherit the name from the controller. The name
   is only inherited from the controller when the action template is null or empty.

4. Multiple attribute routes with different templates and the same name are not allowed.
2014-08-29 17:51:12 -07:00
Ryan Nowak b72b44c20c Implement RouteKeyHandling.CatchAll 2014-08-14 15:59:09 -07:00
Javier Calvarro Nelson 3ab0c3af29 [Issue #733] Attribute Routing: Implement Order
1. Added an Order property to IRouteTemplateProvider, ReflectedAttributeRouteModel,
   AttributeRouteInfo, AttributeRouteLinkGenerationEntry and AttributeRouteMatchingEntry.

2. Changed the implementation of AttributeRoute to take the order into account when routing
   incomming requests and generating links.

3. Ensured a stable ordering of route entries with the same order and precedence for route
   matching and link generation based on the template text.

4. Added tests to validate that the precedence gets respected in route matching and link generation.

5. Added tests to validate that the order gets respected in route matching and link generation.

6. Added tests to validate that the order gets respected over the precedence for route matching
   and link generation.

7. Added tests to validate that routes with the same order and precedence expose a stable ordering
   for route matching and link generation.
2014-08-14 11:21:05 -07:00
Javier Calvarro Nelson 63d9625536 [Issue #730] Attribute Routing: Flesh out attributes - Part 2
1. Unsealed the Http*Attributes so that they can be extended and customized.
2. Added the same constructors as HttpGet to the rest of the Http*Attributes.
3. Added unit tests to validate the implementations for the IActionHttpMethodProvider.
4. Added functional tests to cover extra attribute routing scenarios like a test for an
   action with an HttpDeleteAttribute on it and action with AcceptVerbsAttribute and an
   action with a custom HttpMergeAttribute implemented.
2014-08-14 11:21:03 -07:00
Ryan Nowak 2987f98283 Adding parameter replacement 2014-07-29 16:14:57 -07:00
Ryan Nowak 745239f09f Adding Attribute Routing Link Generation 2014-07-21 14:52:38 -07:00
Javier Calvarro Nelson 87c430ae19 [#732] Attribute Routing: Implement `~/` for overriding a prefix
This change allows a user to override a route prefix set using
[Route("...")] on the controller by providing a route template
on the action that starts with "~/" or "/". For example,
[HttpGet("~/...")] or [HttpGet("/...")]

If the user specifies a template in [Route] that starts with "~/"
or "/", we will just strip the prefix from the template and use
the remaining part of the template.

The reason to do this is that there's a reasonable extensibility
scenario where a user can implement a global prefix for routes as
a convention (using IReflectedApplicationModelConvention), and use
~/ to escape that prefix (just like we support with action-level routes).
2014-07-16 09:40:38 -07:00
Ryan Nowak e396f1b451 Adding attribute routing 2014-07-03 18:53:38 -07:00
Ryan Nowak f194723230 Adding tests for convention-based routing 2014-06-26 14:00:42 -07:00