通过Visual Studio 2019运行ASP.NET Core应用

时间:2019-10-16 22:21:18

标签: asp.net-core asp.net-core-3.0

我已经在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";
        }

,因此我认为当该页面出现时,我会在页面上得到“ Hi”字样。为什么我要返回失败响应?

1 个答案:

答案 0 :(得分:0)

如果缺少某些内容,请检查您的启动类,我的示例成功完成了。

干杯