1 回答

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超7個(gè)贊
事實(shí)是NewRoute先檢查,但路由找不到匹配的動(dòng)作。然后它會匹配下一個(gè)路由規(guī)則。
Debug如果您啟用日志記錄級別appSettings.Development.json
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Debug"
}
}
}
并將啟動(dòng)CompatibilityVersion更改為2.1(asp.net core 2.2有另一種EndPoint機(jī)制)
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
運(yùn)行應(yīng)用程序時(shí),您可以在日志中看到整個(gè)過程:
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 關(guān)注
- 204 瀏覽
添加回答
舉報(bào)