C# 对wep api 2采取行动
您好,我正在使用wep api 2创建此路由。我有 在我的WebConfigApi中定义了C# 对wep api 2采取行动,c#,asp.net,asp.net-web-api,asp.net-web-api2,C#,Asp.net,Asp.net Web Api,Asp.net Web Api2,您好,我正在使用wep api 2创建此路由。我有 在我的WebConfigApi中定义了 config.MapHttpAttributeRoutes(); // In Globa.asax GlobalConfiguration.Configure(WebApiConfig.Register); 我的方法被装饰成 [Route("api/pO")] [AcceptVerbs("Getpo")] [HttpGet]
config.MapHttpAttributeRoutes();
// In Globa.asax
GlobalConfiguration.Configure(WebApiConfig.Register);
我的方法被装饰成
[Route("api/pO")]
[AcceptVerbs("Getpo")]
[HttpGet]
public IEnumerable<pOver> Getpo()
{
------
}
我总是出错
"<Error><Message>No HTTP resource was found that matches the request URI 'http://localhost:60482/api/pO/Getp0'.</Message><MessageDetail>No action was found on the controller 'prO' that matches the request.</MessageDetail></Error>"
“未找到与请求URI匹配的HTTP资源”http://localhost:60482/api/pO/Getp0“。在与请求匹配的控制器“prO”上未找到任何操作。”
请让我知道如何正确地装饰它来运行它。
谢谢我想你希望它看起来像这样:
[Route("api/pO/Getpo")]
[HttpGet]
public IEnumerable<pOver> Getpo()
{
------
}
[路由(“api/pO/Getpo”)]
[HttpGet]
公共IEnumerable Getpo()
{
------
}
AcceptVerbs属性用于执行与您在操作中使用的HttpGet属性类似的操作。您可以使用AcceptVerbs(“GET”)代替HttpGet属性
[Route("api/pO/Getpo")]
[HttpGet]
public IEnumerable<pOver> Getpo()
{
------
}