我在asp.net core中创建了一个Web Api,这是Api的内容:
[Route("api/[controller]")]
public class BlogController : Controller
{
public IContext _context { get; set; }
public BlogController(IContext ctx)
{
_context = ctx;
}
[HttpGet]
[Route("api/Blog/GetAllBlog")]
public List<Blog> GetAllBlog()
{
return _context.Blogs.ToList();
}
}
据我所知,在ASP.NET Core(WebApi模板)中,我们不需要像在Asp.net Mvc 5.3及更早版本中需要的注册路由等任何配置。因此,当我尝试通过浏览器或Postman调用
GetAllBlog
,使用该URL http://localhost:14742/api/Blog/GetAllBlog
时,它会出现404错误
,这是什么问题?