I am migrating Asp.net(.net framework) project Asp.net core(.net core 3.1 framework). I am unable to find the alternate to
[RoutePrefix("api/{controller})]
in .net core 3.1?
Any idea, how we can achieve this?
If you put [Route("api/[controller]")] at the controller level, you can use [Route("Action")] on the method, and the route will be site.com/api/controller/Action.
Something to note is that if you use Route("/Action")] (with a slash), it will overwrite the controller-level route and just give you the action (site.com/Action)
Routeattribute.[HttpGet]attribute on that method... and your route would be something like:[Route("~/api/People/GetData")].