.net - .NET5 Web API 返回 404 Not Found
问题描述
我正在本地计算机 (Win10) 上设置我的第一个 .NET5 Web API。为了测试,我制作了这个简单的控制器:
namespace API.Controllers
{
public class TestController : Controller
{
[HttpGet]
[Route("/test/hallo")]
public string TestMethod()
{
return "Hallo";
}
}
}
从 VS2019 运行/调试代码时,会打开此 URL:https://localhost:5001/swagger/index.html
当我在 Swagger 页面中执行“test/hallo”时,它会按预期返回“Hallo”。
请求 URL 为:https://localhost:5001/test/hallo
到目前为止,一切都很好!
当我尝试从 Google Advanced REST Client 运行 API 时,问题就来了。我在请求 URL 中选择 Method = "Get" 和 "https://api.mydomain/test/hallo"。它返回 404 Not Found。
本地域“api.mydomain”在我的计算机上使用自签名证书。它似乎工作正常,我已经通过在项目根目录中添加“test.html”来测试它。在 Google Chrome 中打开https://api.mydomain/test.html时,页面显示正确。
最大的问题是:尝试使用 Google 高级 REST 客户端访问具有本地域 (api.mydomain) 的 API 时,为什么会得到“404 Not Found”?
解决方案
推荐阅读
- c++ - 由于“%”的事情,它没有对模数执行操作
- php - Wordpress:打开元机器人之前有很多空间
- javascript - Fabricjs 过滤器
- python - 如果这是愚蠢的问题,我是 Djangio 的初学者,请原谅我。在 Django 中 order_by() 究竟做了什么?
- git - 是否可以比较同一存储库的两个远程版本?
- r - 使用 if 语句根据列中的值删除行
- modbus - Twincat 3:Modbus 错误 4“广告邮箱已满”在以前工作的项目中立即打开
- git - git: directory 似乎是带有修改和子模块的目录
- python - TypeError:“FlaubertModel”对象不可迭代
- webpack-dev-server - 使用 webpack 用 Cesium.js 构建应用,npm 出现问题