The trick here is to direct the URL to a specific controller and action. Then use the action method overload with the action method switch to switch between GET and POST.
Change the route setup code to this:
app.UseMvc(routes =>
{
routes.MapRoute(
"Settings",
"settings/api/foo",
new {
controller = "Foo",
action = "DoThing",
}
);
});
( - HTTP-) , :
public class FooController : Controller
{
[HttpGet]
public object DoThing()
{
return new
{
ID = "A"
};
}
[HttpPost]
public object DoThing([FromBody]dynamic entity)
{
return new
{
ID = "B"
};
}
}
MVC URL DoThing Foo. , : ", , , , !" [HttpGet] [HttpPost], , , , .