Below is my controller and action:
[RoutePrefix("api/PaymentManagementController")]
public class PaymentManagementController : ApiController
{
[HttpGet]
[Route("")]
public HttpResponseMessage CheckStatus(string commandType, string account, string txnId)
{
}
}
Here is WebApi.config:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/",
defaults: new { id = RouteParameter.Optional }
This link is working:
localhost:59253/api/PaymentManagementController?commandType=check&account=ParamValue1&txnId=SomePrefix0123456789
However, I expected it as:
localhost:59253/api/PaymentManagementController/CheckStatus?commandType=check&account=ParamValue1&txnId=SomePrefix0123456789
Even after marking Routing as below:
[RoutePrefix("api/PaymentManagementController")]
public class PaymentManagementController : ApiController
{
[HttpGet]
[Route("CheckStatus/{commandType}/{account}/{txnId}")]
public HttpResponseMessage CheckStatus(string commandType, string account, string txnId)
{
}
}
I receive error as:
No HTTP resource was found that matches the request URI 'localhost:59253/api/PaymentManagementController?commandType=check&account=ParamValue1&txnId=SomePrefix0123456789'. No action was found on the controller 'PaymentManagement' that matches the request.