Ниже мой контроллер и действие:
[RoutePrefix("api/PaymentManagementController")]
public class PaymentManagementController : ApiController
{
[HttpGet]
[Route("")]
public HttpResponseMessage CheckStatus(string commandType, string account, string txnId)
{
}
}
Вот WebApi.config:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/",
defaults: new { id = RouteParameter.Optional }
Ссылка работает:
локальный: 59253 / API / PaymentManagementController CommandType = проверить и счета = ParamValue1 & txnId = SomePrefix0123456789
Тем не менее, я ожидал, что это:
локальный: 59253 / API / PaymentManagementController / CheckStatus CommandType = проверить и счета = ParamValue1 & txnId = SomePrefix0123456789
Даже после маркировки маршрутизации, как показано ниже:
[RoutePrefix("api/PaymentManagementController")]
public class PaymentManagementController : ApiController
{
[HttpGet]
[Route("CheckStatus/{commandType}/{account}/{txnId}")]
public HttpResponseMessage CheckStatus(string commandType, string account, string txnId)
{
}
}
Я получаю сообщение об ошибке:
Не был найден ресурс HTTP, который соответствует URI запроса 'localhost: 59253 / api / PaymentManagementController? CommandType = check & account = ParamValue1 & txnId = SomePrefix0123456789'.
На контроллере «PaymentManagement» не найдено никаких действий, соответствующих запросу.