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

Edited Unassigned: Have RouteAttribute for attribute routing [988]

$
0
0
Reading/writing the following code is a bit non-intuitive:
public class HomeController : ApiController
{
[HttpGet("")]
public string Get()
{
return "Hello, World!";
}
}


1. Why do I need to say Get again in the routing attribute? I already did in my method name.
2. It doesn't look like a routing attribute. I'd prefer it to be called Route, to make it explicit I'm setting a route.
3. It would be nice to be able to specify the full path, including the /.

So my preferred syntax would be:
public class HomeController : ApiController
{
[Route("/")]
public string Get()
{
return "Hello, World!";
}
}

(That's what I initially tried to type when using this feature for the first time.)

Also, using [HttpGet] isn't great, as I believe it disables support for HttpHead. In general, I think [Route], would be a better approach.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>