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.
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.