asp.net-core - 通过 Visual Studio 2019 运行 ASP.NET Core 应用程序
问题描述
我在 Visual Studio 2019 中创建了一个新的 ASP.NET Core 应用程序(只是一个 API,而不是 Razor),当我按 F5 时,它会在浏览器中打开一个页面“ https://localhost:44357/space/test " 这给出了 404 错误。控制器定义如下:
[Route("[controller]")]
[ApiController]
public class SpaceController : ControllerBase
{
[HttpGet("test")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<string>> GetTestAsync()
{
return "Hi";
}
所以我会假设当它到达那里时我会在页面上得到一个“嗨”。为什么我会收到失败响应?
解决方案
如果缺少某些东西,请检查您的启动课程,我在您的示例中取得了成功。
推荐阅读
- javascript - 如何使用 jQuery 将存储在变量中的图像文件发送到 php
- python - 我怎样才能让这些柜台装饰器为我的课堂方法工作
- openssl - Openssl 拒绝验证签名
- python - pymysql批量检索数据
- angular - 库中的 APP_INITIALIZER 导致“不支持 Lambda”错误
- php - PHP 临时目录问题
- xml - 将 XML 转换为资源字典
- python - 在另一台计算机上运行的 python 脚本的远程控制功能
- firebase - 为什么在 Firebase 云函数中创建的存储桶不会出现在控制台中?
- python - 从 Python3.7 导入 wxPython 时出现 ImprtError