program.cs增加contrller支持
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.MapControllers();//增加controllers映射
app.Run();
AdminController.cs
[Route("api/[controller]/[action]")]
[ApiController]
public class AdminController : ControllerBase
{
[HttpGet]
public string AdminInfo()
{
return "AdminInfo";
}
}
运行:
标签:core,apicontroller,web,app,6.0,cs,net From: https://www.cnblogs.com/kobewang/p/16727834.html