In my asp.net core application, we are using the default MVC routing in App StartUp configuration.
Then in our controller, we have the following code for one of our api endpoint method:
[HttpGet]
[Route("services/task/{taskid?}/{taskmessage?}")]
[Produces("text/html")]
public async Task<ActionResult> TaskMessage(string taskId = null, string queue = null, string taskmessage = null)
Then we are trying to call the endpoint by passing taskmessage only as the following URL:
http://localhost:12345/api/services/task?taskmessage=hello
However, it's not working here. Can anyone please let me know where did I got wrong? It was working in our ASP.Net project, but once we migrated to the ASP.NET core, it's not working.
BTW, the version of ASP.NET core F/W we are currently using is ASP.NET Core 2.1, if it matters.
not workingmean? Are you getting any errors?[FromQuery]for query string parameters. Like this:([FromQuery] string taskMessage). You can use it for multiple parameters. And the template in theRouteattribute is simpler.HttpGetattribute and supply the route template there.[HttpGet("route/template")]. The[Route]attribute means the action will accept all HTTP verbs. learn.microsoft.com/en-us/aspnet/core/mvc/controllers/… ... See the green tip in that section.