【发布时间】:2020-10-20 06:06:42
【问题描述】:
我正在使用 ASP.NET Core 3.1 MVC 和领域。
这个问题发生在使用 IIS Express 的开发中,我什至还没有达到可以部署到实时 (IIS) 服务器的程度。服务器在启动过程结束时抛出错误 500。
例外:
Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException:请求匹配多个端点。
匹配:
FleetLogix.Intranet.Areas.Maps.Controllers.HomeController.Index (FleetLogix.Intranet)
FleetLogix.Intranet.Areas.Admin.Controllers.HomeController.Index (FleetLogix.Intranet)
FleetLogix.Intranet.Controllers.HomeController.Index (FleetLogix.Intranet)在 Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(CandidateState[] CandidateState)
在 Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ProcessFinalCandidates(HttpContext httpContext, CandidateState[] CandidateState)
在 Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.Select(HttpContext httpContext, CandidateState[] CandidateState)
在 Microsoft.AspNetCore.Routing.Matching.DfaMatcher.MatchAsync(HttpContext httpContext)
在 Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher.MatchAsync(HttpContext httpContext)
在 Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
在 Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext 上下文)
在 Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware.Invoke(HttpContext 上下文)
在 Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext 上下文)
这是我的路线:
app.UseEndpoints(endpoints =>
{
endpoints.MapAreaControllerRoute(
name: "AdminArea",
areaName: "Admin",
pattern: "Admin/{controller=Home}/{action=Index}/{id?}");
endpoints.MapAreaControllerRoute(
name: "AnchorArea",
areaName: "Anchor",
pattern: "Anchor/{controller=Home}/{action=Index}/{id?}");
endpoints.MapAreaControllerRoute(
name: "DashboardArea",
areaName: "Dashboard",
pattern: "Dashboard/{controller=DriverBehaviour}/{action=Index}/{id?}");
endpoints.MapAreaControllerRoute(
name: "MapsArea",
areaName: "Maps",
pattern: "Maps/{controller=Home}/{action=Index}/{id?}");
endpoints.MapAreaControllerRoute(
name: "ReportGroupsArea",
areaName: "ReportGroups",
pattern: "ReportGroups/{controller=Home}/{action=Index}/{id?}");
endpoints.MapAreaControllerRoute(
name: "MaintenanceArea",
areaName: "Maintenance",
pattern: "Maintenance/{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllers();
endpoints.MapRazorPages();
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
我没有做任何特别的事情。我已经看到了说要向方法添加属性的修复程序,例如:
[HttpGet("{id:int}")]
但这是在抱怨具有相同配置文件的基本索引方法。通往他们的道路是为了区分。
我该如何解决这个问题?
【问题讨论】:
标签: asp.net-mvc asp.net-core routes