Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Created Unassigned: Add RouteAttribute, remove attribute routing properties from HttpXxxAttributes [1204]

$
0
0
Merging attribute routing with the existing HttpXxxAttributes causes a couple of issues:
* When using Web API conventions you end up repeating yourself on what HTTP verb is handled by the action:
[HttpGet("foo")]
public Foo GetFoo() { ... }
* It's not clear what [HttpGet("")] and [HttpGet] mean. Typically you would expect these two cases to be equivalent but with attribute routing they are not (the first adds a route, the second doesn't).

The proposal is remove the attribute routing semantics from the HttpXxxAttributes and instead have a separate RouteAttribute. This separates the concerns of HTTP verb filtering and attribute routing:
[Route("foo")]
public Foo GetFoo() { ... }

With the new RouteAttribute the semantics of [Route] and [Route("")] would be the same - both add a route at the root, so a simple ValuesController would look like this:

```
[RoutePrefix("api/values")]
public class ValuesController : ApiController
{
[Route]
public IEnumerable<String> GetValues() { ... }
[Route("{id}")]
public string GetValue(int id) { ... }
[Route]
public void PostValue(string value) { ... }
[Route("{id}")]
public void PutValue(int id, string value) { ... }
[Route("{id}")]
public void DeleteValue(int id) { ... }
}

```

Viewing all articles
Browse latest Browse all 7215

Trending Articles