I am trying to get OData to work in ASP.Net 2.1. The main Get is ok as I get the results from the DB.
When I try to call the second Get with a Parameter it returns with a 404. I put a breakpoint on the second get and it never hits. The http "get" statement http://localhost:5000/odata/userrole('Admin')
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:5000/odata/userrole('Admin')
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 423.7117ms 404
What am I not doing right here? Thank you.
Microsoft.AspNetCore.Odata = v7.1.0
namespace MyApp.Controllers
{
public class UserRoleController : ODataController
{
private IMyDB _db;
public UserRoleController(IMyDB db)
{
_db = db;
}
[EnableQuery(PageSize = 20)]
public IActionResult Get()
{
return Ok(_db.UserRole().AsQueryable());
}
[EnableQuery]
public IActionResult Get([FromODataUri] string roletype)
{
return Ok(_db.UserRole().Find(roletype));
}
}
}