简体   繁体   English

为什么这里“找不到与请求 URI 匹配的 HTTP 资源”?

[英]Why is it that "No HTTP resource was found that matches the request URI" here?

I have code in my controller like so:我的控制器中有这样的代码:

[Route("api/deliveryitems/InsertIntoPPTData/{stringifiedRecord}")]

...and I'm calling it via Postman like so: ...我是这样通过 Postman 调用它的:

    http://localhost:21609/api/deliveryitems/InsertIntoPPTData?
stringifiedRecord=serNum77;tx2;siteNum2;bla2.xml;ppt_user2;tx_memo2;file_beg2;file_end2

...but get: ...但是得到:

{
Message: "No HTTP resource was found that matches the request URI     
'http://localhost:21609/api/deliveryitems/InsertIntoPPTData?   stringifiedRecord=serNum77;tx2;siteNum2;bla2.xml;ppt_user2;tx_memo2;file_beg2;file_end2'."
MessageDetail: "No type was found that matches the controller named 'deliveryitems'."
}

Other REST methods that are created and called in the same way are found just fine - why not this one?发现以相同方式创建和调用的其他 REST 方法都很好 - 为什么不是这个? The only thing it does not have in common with the others is that it is a HttpPost, whereas the others are HttpGet.它与其他的唯一不同之处在于它是一个 HttpPost,而其他的是 HttpGet。 Does that make that much of a difference?这有那么大的不同吗? I am selecting "Post" from the dropdown in Postman when trying to call this REST method.尝试调用此 REST 方法时,从 Postman 的下拉列表中选择“Post”。

UPDATE更新

Yes, it apparently has nothing to do with it being a Post and passing args in the URI, because I'm getting the same thing now with an HttpGet method:是的,它显然与它是一个 Post 并在 URI 中传递 args 无关,因为我现在使用 HttpGet 方法得到了同样的东西:

{
Message: "No HTTP resource was found that matches the request URI     
'http://localhost:21609/api/department/getndeptsfromid?firstId=2&countToFetch=12'."
MessageDetail: "No action was found on the controller 'Department' that matches the request."
}

I'm calling it from postman like so:我是这样从邮递员那里打电话的:

http://localhost:21609/api/department/getndeptsfromid?firstId=2&countToFetch=12

...and it does indeed appear in my controller: ...它确实出现在我的控制器中:

[HttpGet]
[Route("api/department/getndeptsfromid/{firstId}/{countToFetch}")]
public List<Department> GetNDepartmentsFromID(int FirstId, int CountToFetch)
{
    return CCRService.GetNDepartmentsFromID(FirstId, CountToFetch);
}

UPDATE 2更新 2

I thought I was about to solve it when I changed this code:当我更改这段代码时,我以为我即将解决它:

String.Format("api/department/getndeptsfromid/{0}/{1}", FirstId, CountToFetch)

...to this: ...对此:

String.Format("api/department/getndeptsfromid?firstId={0}&countToFetch={1}", FirstId, CountToFetch)

...but I still get the same err msg... ...但我仍然收到相同的错误消息...

UPDATE 3更新 3

I find that this also is not working:我发现这也不起作用:

http://localhost:21609/api/delivery/invnumbyid?ID=33

...and so there is a definite pattern. ...所以有一个明确的模式。 EVERY REST API call I make that contains args/params fails in this same way;我进行的每个包含 args/params 的 REST API 调用都以同样的方式失败; all of the others ( http://localhost:21609/api/deliveries/Count, http://localhost:21609/api/deliveryitems/count, http://localhost:21609/api/department/getall ) work just fine.所有其他的( http://localhost:21609/api/deliveries/Count, http://localhost:21609/api/deliveryitems/count, http://localhost:21609/api/department/getall )工作得很好. IOW, if there are no args in the URI, the method is discovered. IOW,如果 URI 中没有参数,就会发现该方法。 If there are args, it is not.如果参数,则没有。

So apparently there's either something wrong with how I'm passing the args/vals in the URI (appending " ?= " in the case of a single arg and, in the case of two args " ?=&= ") and/or there's something wrong with how I set up the routing.所以显然我在 URI 中传递 args/vals 的方式有问题(在单个 arg 的情况下附加“ ?= ”,在两个 args 的情况下附加“ ?=&= ”)和/或我设置路由的方式有问题。 Specifically, this style works:具体来说,这种风格适用于:

[Route("api/Deliveries/Count")]

...whereas this style does not: ...而这种风格不会:

[Route("api/delivery/invnumbyid/{ID}")]

I will bountify this question ASAP - 50 points to the untangler of this Gordiesque knot, and 100 if it's answered today (prior to the setting up of the bounty).我会尽快悬赏这个问题——解开这个戈尔迪斯结的人获得 50 分,如果今天(在设置赏金之前)得到回答,则获得 100 分。

UPDATE 4更新 4

I changed the routing to include the data type of the arg so that this:我更改了路由以包含 arg 的数据类型,这样:

[Route("api/delivery/invnumbyid/{ID}")]

-became this: -变成了这个:

[Route("api/delivery/invnumbyid/{ID:int}")]"

But it still failed, growling:但还是失败了,咆哮道:

{
Message: "No HTTP resource was found that matches the request URI 
'http://localhost:21609/api/delivery/invnumbyid?ID=45'."
MessageDetail: "No action was found on the controller 'Delivery' that matches the request."
}

Then, "on a lark," I tried entering this into Postman:然后,“开玩笑”,我尝试将其输入 Postman:

http://localhost:21609/api/delivery/invnumbyid/45

...and it worked! ...它奏效了! (I had been thinking it needed to be " http://localhost:21609/api/delivery/invnumbyid?ID=45 ") (我一直认为它需要是“ http://localhost:21609/api/delivery/invnumbyid?ID=45 ”)

But a similar attempt in Postman:但是在 Postman 中有类似的尝试:

http://localhost:21609/api/department/getndeptsfromid/2/12/

...continues to fail with "No value given for one or more required parameters." ...继续失败,并显示“没有为一个或多个必需参数提供值”。 even though this is hit:即使这是命中:

[HttpGet]
[Route("api/department/getndeptsfromid/{firstId}/{countToFetch}")]
public List<Department> GetNDepartmentsFromID(int FirstId, int CountToFetch)
{
    return HHSService.GetNDepartmentsFromID(FirstId, CountToFetch);
}

...and the args to GetNDepartmentsFromID() has the expected vals (2 and 12) ...并且 GetNDepartmentsFromID() 的参数具有预期的值(2 和 12)

Even worse/weirder is the result I get with " http://localhost:21609/api/deliveryitems/InsertIntoPPTData/serNum77;tx2;siteNum2;bla2.xml;ppt_user2;tx_memo2;file_beg2;file_end2 " now:更糟糕/更奇怪的是我现在使用“ http://localhost:21609/api/deliveryitems/InsertIntoPPTData/serNum77;tx2;siteNum2;bla2.xml;ppt_user2;tx_memo2;file_beg2;file_end2 ”得到的结果:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
    xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>IIS 8.0 Detailed Error - 404.0 - Not Found</title>
        <style type="text/css">
            <!-- 
body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;} 
code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;} 
.config_source code{font-size:.8em;color:#000000;} 
pre{margin:0;font-size:1.4em;word-wrap:break-word;} 
ul,ol{margin:10px 0 10px 5px;} 
ul.first,ol.first{margin-top:5px;} 
fieldset{padding:0 15px 10px 15px;word-break:break-all;} 
.summary-container fieldset{padding-bottom:5px;margin-top:4px;} 
legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;} 
legend{color:#333333;;margin:4px 0 8px -12px;_margin-top:0px; 
font-weight:bold;font-size:1em;} 
a:link,a:visited{color:#007EFF;font-weight:bold;} 
a:hover{text-decoration:none;} 
h1{font-size:2.4em;margin:0;color:#FFF;} 
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.4em;margin:10px 0 0 0;color:#CC0000;} 
h4{font-size:1.2em;margin:10px 0 5px 0; 
}#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS",Verdana,sans-serif; 
 color:#FFF;background-color:#5C87B2; 
}#content{margin:0 0 0 2%;position:relative;} 
.summary-container,.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;} 
.content-container p{margin:0 0 10px 0; 
}#details-left{width:35%;float:left;margin-right:2%; 
}#details-right{width:63%;float:left;overflow:hidden; 
}#server_version{width:96%;_height:1px;min-height:1px;margin:0 0 5px 0;padding:11px 2% 8px 2%;color:#FFFFFF; 
 background-color:#5A7FA5;border-bottom:1px solid #C1CFDD;border-top:1px solid #4A6C8E;font-weight:normal; 
 font-size:1em;color:#FFF;text-align:right; 
}#server_version p{margin:5px 0;} 
table{margin:4px 0 4px 0;width:100%;border:none;} 
td,th{vertical-align:top;padding:3px 0;text-align:left;font-weight:normal;border:none;} 
th{width:30%;text-align:right;padding-right:2%;font-weight:bold;} 
thead th{background-color:#ebebeb;width:25%; 
}#details-right th{width:20%;} 
table tr.alt td,table tr.alt th{} 
.highlight-code{color:#CC0000;font-weight:bold;font-style:italic;} 
.clear{clear:both;} 
.preferred{padding:0 5px 2px 5px;font-weight:normal;background:#006633;color:#FFF;font-size:.8em;} 
-->
        </style>
    </head>
    <body>
        <div id="content">
            <div class="content-container">
                <h3>HTTP Error 404.0 - Not Found</h3>
                <h4>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h4>
            </div>
            <div class="content-container">
                <fieldset>
                    <h4>Most likely causes:</h4>
                    <ul>
                        <li>The directory or file specified does not exist on the Web server.</li>
                        <li>The URL contains a typographical error.</li>
                        <li>A custom filter or module, such as URLScan, restricts access to the file.</li>
                    </ul>
                </fieldset>
            </div>
            <div class="content-container">
                <fieldset>
                    <h4>Things you can try:</h4>
                    <ul>
                        <li>Create the content on the Web server.</li>
                        <li>Review the browser URL.</li>
                        <li>Check the failed request tracing log and see which module is calling SetStatus. For more information, click 
                            <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. 
                        </li>
                    </ul>
                </fieldset>
            </div>
            <div class="content-container">
                <fieldset>
                    <h4>Detailed Error Information:</h4>
                    <div id="details-left">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr class="alt">
                                <th>Module</th>
                                <td>&nbsp;&nbsp;&nbsp;IIS Web Core</td>
                            </tr>
                            <tr>
                                <th>Notification</th>
                                <td>&nbsp;&nbsp;&nbsp;MapRequestHandler</td>
                            </tr>
                            <tr class="alt">
                                <th>Handler</th>
                                <td>&nbsp;&nbsp;&nbsp;StaticFile</td>
                            </tr>
                            <tr>
                                <th>Error Code</th>
                                <td>&nbsp;&nbsp;&nbsp;0x80070002</td>
                            </tr>
                        </table>
                    </div>
                    <div id="details-right">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr class="alt">
                                <th>Requested URL</th>
                                <td>&nbsp;&nbsp;&nbsp;http://localhost:21609/api/deliveryitems/InsertIntoPPTData/serNum77;tx2;siteNum2;bla2.xml;ppt_user2;tx_memo2;file_beg2;file_end2</td>
                            </tr>
                            <tr>
                                <th>Physical Path</th>
                                <td>&nbsp;&nbsp;&nbsp;C:\project\git\CStore\HHS.API\api\deliveryitems\InsertIntoPPTData\serNum77;tx2;siteNum2;bla2.xml;ppt_user2;tx_memo2;file_beg2;file_end2</td>
                            </tr>
                            <tr class="alt">
                                <th>Logon Method</th>
                                <td>&nbsp;&nbsp;&nbsp;Anonymous</td>
                            </tr>
                            <tr>
                                <th>Logon User</th>
                                <td>&nbsp;&nbsp;&nbsp;Anonymous</td>
                            </tr>
                            <tr class="alt">
                                <th>Request Tracing Directory</th>
                                <td>&nbsp;&nbsp;&nbsp;C:\Users\clay\Documents\IISExpress\TraceLogFiles\HHS.API</td>
                            </tr>
                        </table>
                        <div class="clear"></div>
                    </div>
                </fieldset>
            </div>
            <div class="content-container">
                <fieldset>
                    <h4>More Information:</h4> 
  This error means that the file or directory does not exist on the server. Create the file or directory and try the request again. 

                    <p>
                        <a href="http://go.microsoft.com/fwlink/?LinkID=62293&amp;IIS70Error=404,0,0x80070002,7601">View more information &raquo;</a>
                    </p>
                </fieldset>
            </div>
        </div>
    </body>
</html> 

¡Que demonios! ¡Que demonios!

I sadly smilingly remember that there is always one more gargoyle hiding behind the rustling curtain (where Robinson Jeffers and Edgar Allen Poe are seemingly wrestling).我悲伤地微笑着记得,在沙沙作响的窗帘后面(罗宾逊·杰弗斯和埃德加·艾伦·坡似乎正在摔跤)后面总是藏着一个石像鬼。 Palely loitering...苍白的游荡...

UPDATE 5更新 5

Okay, here it is stated differently:好的,这里有不同的说法:

From Postman, if I use this URL:来自 Postman,如果我使用此 URL:

http://localhost:21609/api/department/getndeptsfromid/2/12/

I make it into this method:我把它变成了这个方法:

[HttpGet]
[Route("api/department/getndeptsfromid/{firstId}/{countToFetch}")]
public List<Department> GetNDepartmentsFromID(int FirstId, int CountToFetch)
{
    return HHSService.GetNDepartmentsFromID(FirstId, CountToFetch);
}

...where the value of FirstId is 2, and the value of CountToFetch is 12 (as I would expect them to be). ...其中 FirstId 的值为 2,而 CountToFetch 的值为 12(正如我所期望的那样)。 But then, Postman sends back my package with the notation, " 500 No value given for one or more required parameters. "但是随后,邮递员发回了我的包裹,上面写着“ 500 No value given for one or more required parameters.

¡Que demonios! ¡Que demonios! Both parameters were obviously passed!两个参数明显都传过去了!

If I use a URI that would seem more correct:如果我使用一个看起来更正确的 URI:

http://localhost:21609/api/department/getndeptsfromid?firstId=2&countToFetch=12

I get:我得到:

{
Message: "No HTTP resource was found that matches the request URI   
'http://localhost:21609/api/department/getndeptsfromid?firstId=2&countToFetch=12'."
MessageDetail: "No action was found on the controller 'Department' that matches the request."
}

Yet this is the route that I've provided:然而,这是我提供的路线:

[Route("api/department/getndeptsfromid/{firstId}/{countToFetch}")]

...and so I would say that I did, in fact, provide a matching action on the controller.And, BTW, if I just enter this as the URI into Postman: ...所以我会说我确实在控制器上提供了匹配操作。顺便说一句,如果我只是将它作为 URI 输入到 Postman 中:

http://localhost:21609/api/department/getndeptsfromid

...and then use Postman's "URL Parameter Key / Value" interface to add those, it generates the exact same URL as above, as can be seen here: ...然后使用 Postman 的“URL Parameter Key / Value”接口添加这些,它生成与上面完全相同的 URL,如下所示:

在此处输入图像描述

...and with the exact same result. ...并得到完全相同的结果。

I can only say it again (pardon my " Las Uvas de la Ira "-inspired Spanish): ¡Que demonios!我只能再说一遍(请原谅我的“ Las Uvas de la Ira ”灵感源自西班牙语): ¡Que demonios!

Your problems have nothing to do with POST/GET but only with how you specify parameters in RouteAttribute .您的问题与 POST/GET 无关,而仅与您在RouteAttribute指定参数的方式RouteAttribute To ensure this, I added support for both verbs in my samples.为确保这一点,我在示例中添加了对这两个动词的支持。

Let's go back to two very simple working examples.让我们回到两个非常简单的工作示例。

[Route("api/deliveryitems/{anyString}")]
[HttpGet, HttpPost]
public HttpResponseMessage GetDeliveryItemsOne(string anyString)
{
    return Request.CreateResponse<string>(HttpStatusCode.OK, anyString);
}

And

[Route("api/deliveryitems")]
[HttpGet, HttpPost]
public HttpResponseMessage GetDeliveryItemsTwo(string anyString = "default")
{
    return Request.CreateResponse<string>(HttpStatusCode.OK, anyString);
}

The first sample says that the " anyString " is a path segment parameter (part of the URL).第一个示例表示“ anyString ”是路径段参数(URL 的一部分)。

First sample example URL is:第一个示例 URL 是:

  • localhost: xxx/api/deliveryItems/dkjd;dslkf;dfk;kkklm;oeop本地主机: xxx/api/deliveryItems/dkjd;dslkf;dfk;kkklm;oeop
    • returns "dkjd;dslkf;dfk;kkklm;oeop"返回"dkjd;dslkf;dfk;kkklm;oeop"

The second sample says that the " anyString " is a query string parameter (optional here since a default value has been provided, but you can make it non-optional by simply removing the default value).第二个示例表示“ anyString ”是一个查询字符串参数(这里是可选的,因为已经提供了默认值,但您可以通过简单地删除默认值来使其成为非可选)。

Second sample examples URL are:第二个示例示例 URL 是:

  • localhost: xxx/api/deliveryItems?anyString=dkjd;dslkf;dfk;kkklm;oeop本地主机: xxx/api/deliveryItems?anyString=dkjd;dslkf;dfk;kkklm;oeop
    • returns "dkjd;dslkf;dfk;kkklm;oeop"返回"dkjd;dslkf;dfk;kkklm;oeop"
  • localhost: xxx/api/deliveryItems本地主机: xxx/api/deliveryItems
    • returns "default"返回"default"

Of course, you can make it even more complex, like with this third sample:当然,你可以让它更复杂,就像第三个示例:

[Route("api/deliveryitems")]
[HttpGet, HttpPost]
public HttpResponseMessage GetDeliveryItemsThree(string anyString, string anotherString = "anotherDefault")
{
    return Request.CreateResponse<string>(HttpStatusCode.OK, anyString + "||" + anotherString);
}

Third sample examples URL are:第三个示例示例 URL 是:

  • localhost: xxx/api/deliveryItems?anyString=dkjd;dslkf;dfk;kkklm;oeop本地主机: xxx/api/deliveryItems?anyString=dkjd;dslkf;dfk;kkklm;oeop
    • returns "dkjd;dslkf;dfk;kkklm;oeop||anotherDefault"返回"dkjd;dslkf;dfk;kkklm;oeop||anotherDefault"
  • localhost: xxx/api/deliveryItems本地主机: xxx/api/deliveryItems
    • returns "No HTTP resource was found that matches the request URI ..." (parameter anyString is mandatory)返回“未找到与请求 URI 匹配的 HTTP 资源...”(参数anyString是必需的)
  • localhost: xxx/api/deliveryItems?anotherString=bluberb&anyString=dkjd;dslkf;dfk;kkklm;oeop本地主机: xxx/api/deliveryItems?anotherString=bluberb&anyString=dkjd;dslkf;dfk;kkklm;oeop
    • returns "dkjd;dslkf;dfk;kkklm;oeop||bluberb"返回"dkjd;dslkf;dfk;kkklm;oeop||bluberb"
    • note that the parameters have been reversed, which does not matter, this is not possible with "URL-style" of first example请注意,参数已被颠倒,这无关紧要,这对于第一个示例的“URL-style”是不可能的

When should you use path segment or query parameters?什么时候应该使用路径段或查询参数? Some advice has already been given here: REST API Best practices: Where to put parameters?这里已经给出了一些建议: REST API 最佳实践:参数放在哪里?

Have you tried using the [FromUri] attribute when sending parameters over the query string.通过查询字符串发送参数时,您是否尝试过使用[FromUri]属性。

Here is an example:下面是一个例子:

[HttpGet]
[Route("api/department/getndeptsfromid")]
public List<Department> GetNDepartmentsFromID([FromUri]int FirstId, [FromUri] int CountToFetch)
{
    return HHSService.GetNDepartmentsFromID(FirstId, CountToFetch);
}

Include this package at the top also, using System.Web.Http;在顶部也包含这个包, using System.Web.Http;

WebApiConfig.Register(GlobalConfiguration.Configuration); should be on top.

I had that problem, if you are calling your REST Methods from another Assembly you must be sure that all your references have the same version as your main project references, otherwise will never find your controllers.我遇到了这个问题,如果你从另一个程序集中调用你的 REST 方法,你必须确保你的所有引用与你的主项目引用具有相同的版本,否则将永远找不到你的控制器。

Regards.问候。

Try this mate, you can chuck it in the body like so...试试这个伙伴,你可以像这样把它扔进身体里……

    [HttpPost]
    [Route("~/API/ChangeTheNameIfNeeded")]
    public bool SampleCall([FromBody]JObject data)
    {
        var firstName = data["firstName"].ToString();
        var lastName= data["lastName"].ToString();
        var email = data["email"].ToString();
        var obj= data["toLastName"].ToObject<SomeObject>();

        return _someService.DoYourBiz(firstName, lastName, email, obj);
    }

I got the similiar issue, and resolved it by the following.我遇到了类似的问题,并通过以下方式解决了它。 The issue looks not related to the Route definition but definition of the parameters, just need to give it a default value.这个问题看起来与Route定义无关,而是与参数定义有关,只需要给它一个默认值即可。

----Code with issue: Message: "No HTTP resource was found that matches the request URI ----代码问题:消息:“未找到与请求 URI 匹配的 HTTP 资源

    [HttpGet]
    [Route("students/list")]
    public StudentListResponse GetStudents(int? ClassId, int? GradeId)
    {
       ...
    }

----Code without issue. ----代码没有问题。

    [HttpGet]
    [Route("students/list")]
    public StudentListResponse GetStudents(int? ClassId=null, int? GradeId=null)
    {
       ...
    }

You need to map the unique route to specify your parameters as query elements.您需要映射唯一路由以将您的参数指定为查询元素。 In RouteConfig.cs (or WebApiConfig.cs) add:在 RouteConfig.cs(或 WebApiConfig.cs)中添加:

config.Routes.MapHttpRoute(
            name: "MyPagedQuery",
            routeTemplate:     "api/{controller}/{action}/{firstId}/{countToFetch}",
            defaults: new { action = "GetNDepartmentsFromID" }
        );

Just make sure that the controller name is the same as yours DeliveryController if you renamed it (it will not change automatically!).如果您重命名它,只需确保控制器名称与您的 DeliveryController 相同(它不会自动更改!)。 if you rename the project name too you should delete the reference to this project from the Bin folder.如果您也重命名项目名称,则应从 Bin 文件夹中删除对该项目的引用。 Don't forget to specify the method get or post.不要忘记指定 get 或 post 方法。

If it is a GET service, then you need to use it with a GET method, not a POST method.如果它是 GET 服务,那么您需要将它与 GET 方法一起使用,而不是 POST 方法。 Your problem is a type mismatch.您的问题是类型不匹配。 A different example of type mismatch (to put severity into perspective) is trying to assign a string to an integer variable.类型不匹配的另一个示例(从严重性角度考虑)是尝试将字符串分配给整数变量。

Please check the class you inherited.请检查您继承的课程。 Whether it is simply Controller or APIController.不管是简单的Controller还是APIController。

By mistake we might create a controller from MVC 5 controller.我们可能会错误地从 MVC 5 控制器创建一个控制器。 It should be from Web API Controller.它应该来自 Web API 控制器。

Make sure:确保:

  1. the controller name is correctly spelled控制器名称拼写正确
  2. has the correct POST/GET directives具有正确的 POST/GET 指令
  3. you are not missing any parameters in the URL您没有遗漏 URL 中的任何参数

The last one was what caused me trouble.最后一个是给我带来麻烦的。

对于 .net web api,请注意,您的控制器必须从 ApiController 继承,否则,您将收到此错误。

I know this is an old post, but for the sake of posterity, I'm posting my issue/fix (as it wasn't mentioned above) for anyone else who may run into it.我知道这是一篇旧帖子,但为了后代,我将我的问题/修复(因为上面没有提到)发布给可能遇到它的任何其他人。

[HttpGet]
[Route("writebacks/{clientguid}/")]
public List<WritebackInfo> GetWritebacks(string clientiguid) {
    return null;
}

This was my method that wasn't working, even though other methods on the same controller were (eliminating reference versions, or other project level resolutions).这是我的方法行不通,即使同一控制器上的其他方法行得通(消除参考版本或其他项目级解决方案)。

Note the spelling mistake in the parameter in the actual argument list.注意实参列表中参数的拼写错误。

clientiguid instead of clientguid clientiguid而不是clientguid

Fixed that, and it worked.解决了这个问题,它奏效了。 Obviously a mistake, but not so obvious what it was, from the error message, not at first read anyway.显然是一个错误,但从错误消息来看并没有那么明显,无论如何一开始都没有读到。

Live and learn.活到老,学到老。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未找到与Angular 2中的请求URI匹配的HTTP资源 - No HTTP resource was found that matches the request URI in Angular 2 找不到与请求URI&#39;MyUrl&#39;匹配的HTTP资源 - No HTTP resource was found that matches the request URI 'MyUrl' 获取没有与请求URI匹配的HTTP资源 - Getting No HTTP resource was found that matches the request URI 找不到与请求URI匹配的HTTP资源 - No HTTP resource was found that matches the request URI 找不到与webapi中的请求URI匹配的HTTP资源 - No HTTP resource was found that matches the request URI in webapi 未找到与请求URI匹配的HTTP资源,未找到与控制器匹配的类型 - No HTTP resource was found that matches the request URI, No type was found that matches the controller 路由错误:找不到与请求URI匹配的HTTP资源 - Routing error: No HTTP resource was found that matches the request URI 自定义“找不到与请求uri匹配的http资源”消息 - Customizing “No http resource was found that matches the request uri” message 未找到与请求 URI 匹配的 HTTP 资源,我需要解决方案 - No HTTP resource was found that matches the request URI, I need solutions 我收到错误“没有找到与请求 URI 匹配的 HTTP 资源” - I am getting error “No HTTP resource was found that matches the request URI”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM