如何对 Web API 项目进行故障排除?

How do I troubleshoot Web API projects?

我已经尝试过这个 github 存储库 - https://github.com/johnph/simple-transaction 有时它可以工作(我可以登录),有时它不能(即使使用正确的用户名和密码我也无法登录)。当我无法登录时,它只会抛出 No connection could be made because the target machine actively refused itObject reference not set to an instance of an object。此一般消息对我进行故障排除没有帮助。

该项目使用 Application Insights 进行日志记录,但我不想用信用卡注册 Azure 帐户。我尝试在 Web api 项目中放置断点(Identity.WebApi.Controllers,Authenticate 方法),但它也没有到达断点。

通常我们使用 Fidler or postman 来测试网络 api,这些工具让您可以全面测试您的 restfull 服务并查看执行的 http 状态

这里是 fidler 中无效身份验证错误的示例:

当您双击请求时,您可以看到更多详细信息