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

问题描述 投票:0回答:1

[我已经在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”。为什么我要返回失败响应?

asp.net-core asp.net-core-3.0
1个回答
0
投票

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

干杯,

© www.soinside.com 2019 - 2024. All rights reserved.