asp.net-web-api - 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。
解决方案
推荐阅读
- ios-charts - Swift - 格式化 ios 图表 PieEntry 标签以包含显示小时和分钟的自定义标签
- python - 使用 Python 转发包含标题的电子邮件
- python - 打破重复密钥异或,密码集 1,挑战 6
- twitter-bootstrap - 在模态中打开引导选择2
- typescript - 使用声明合并到 ES2015 模块语法重构 TypeScript 代码
- java - 定义有关类字段的元信息的最有效方法是什么
- python - 熊猫数据框总和
- javascript - JavaScript:然后从获取中中断
- python - 如何防止容器在错误期间关闭?
- python - Raise 在我的自定义异常前面加上 __main__