Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Calling a Web API action that has same signature as another

$
0
0

I have an ASP .Net Core 1.1 Web Api. In one of my controllers, I'd like two actions:

[HttpGet("{userId:int}")]
public async Task<IActionResult> GetUser([FromRoute] int id)
{
    return Ok(_context.User.Where(u.Id == id));
}

[HttpGet("{groupId:int}")]
public async Task<IActionResult> GetUsersInGroup([FromRoute] int groupId)
{
    return Ok(_context.User.Where(u.GroupId == groupId));
}

Both actions have the same signature, except for the method name. How can I make it so that I can call upon the one or the other?

Thanks...


Viewing all articles
Browse latest Browse all 9386

Trending Articles



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