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 關注
- 191 瀏覽
添加回答
舉報