I have an ASP.Net Core 3.1 MVC project running at https://localhost:5006 using default routing.
app.UseRouting();
...
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
//endpoints.MapRazorPages();
});
If I browse to https://localhost:5006/Home/Index or even https://localhost:5006/Home, it works as expected. (The Index action of the Home controller is executed.)
But when I browse to https://localhost:5006, I get a blank page in the browser.
Looking at the logs (pasted below), Routing.EndpointMiddleware (or any other middleware) seems to not be running on the request to '/' (like it is on the call to '/Home'. Any ideas of what to look at next to debug this?
Here is output from the Kestrel console:
First Request
info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/2 GET https://localhost:5006/
info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished in 11.5922ms 200
Second Request
info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/2 GET https://localhost:5006/home
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1] Authorization was successful.
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0] Executing endpoint 'Project.Controllers.HomeController.Index (Project)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3] Route matched with {action = "Index", controller = "Home"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Index(Project.Contracts.PageInfo, Project.Contracts.Query) on controller Project.Controllers.HomeController
...
question from:
https://stackoverflow.com/questions/65947150/default-routing-issue-in-asp-net-core-3-1-mvc 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…