首页 > 解决方案 > Asp.net Web API 没有调用正确的方法

问题描述

我正在调用默认的 Account/ResetPassword api,但它没有被击中。其他一些方法可以,我不知道是哪一种。有没有办法逐步完成该过程,以便我可以看到正在调用哪个方法?

这是默认方法:

[HttpPost]
[AllowAnonymous]
[System.Web.Mvc.ValidateAntiForgeryToken]
[Route("api/Account/ResetPassword")]
public async Task<IHttpActionResult> ResetPassword(ResetPasswordViewModel model)

我正在使用 PostMan 来测试通话。顺便说一句,这曾经奏效。在添加了许多其他方法后,它似乎已经停止工作,但我们不确定确切的时间。

更新

我发现正在调用哪个方法。为了防止它,我给它添加了一个 Route 属性。现在我收到以下消息。

{
"Message": "No HTTP resource was found that matches the request URI 'http://localhost:55914/api/Account/ResetPassword'.",
"MessageDetail": "No action was found on the controller 'Account' that matches the request."
}

更新 2

我能够通过从 ResetPassword 中删除路由来解决问题。我不知道为什么这会起作用。我没有从默认帐户控制器中移动 ResetPassword。

标签: asp.net-web-api

解决方案


推荐阅读