1 回答
TA贡献1818条经验 获得超7个赞
事实是NewRoute先检查,但路由找不到匹配的动作。然后它会匹配下一个路由规则。
Debug如果您启用日志记录级别appSettings.Development.json
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Debug"
}
}
}
并将启动CompatibilityVersion更改为2.1(asp.net core 2.2有另一种EndPoint机制)
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
运行应用程序时,您可以在日志中看到整个过程:
dbug: Microsoft.AspNetCore.Routing.RouteBase[1]
Request successfully matched the route with name 'NewRoute' and template '/'
dbug: Microsoft.AspNetCore.Mvc.Internal.ActionSelector[3]
No actions matched the current request. Route values: controller=Home
dbug: Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler[3]
No actions matched the current request. Route values: controller=Home
dbug: Microsoft.AspNetCore.Routing.RouteBase[1]
Request successfully matched the route with name 'default' and template '{controller=Home}/{action=Index}/{id?}'
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
Route matched with {action = "Index", controller = "Home"}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult Index() on controller Core22MVC.Controllers.HomeController (Core22MVC).
匹配两次并选择default路线。
- 1 回答
- 0 关注
- 148 浏览
添加回答
举报