Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 对wep api 2采取行动_C#_Asp.net_Asp.net Web Api_Asp.net Web Api2 - Fatal编程技术网

C# 对wep api 2采取行动

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]

您好,我正在使用wep api 2创建此路由。我有

在我的WebConfigApi中定义了

    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()
 {
        ------
 }