C# 404具有现有路由的现有页面上出现错误 问题

C# 404具有现有路由的现有页面上出现错误 问题,c#,asp.net,asp.net-mvc,routes,http-status-code-404,C#,Asp.net,Asp.net Mvc,Routes,Http Status Code 404,404错误onhttps://localhost:44300/services当页面和路由存在时 问题 是什么导致了这个路由问题 注意到的意见 我不明白的是,目录中的内容是如何显示的,比如https://localhost:44300/&https://localhost:44300/articles是唯一有效的方法 GitHub项目 感兴趣的文件 /区域/物品/物品注册EA.cs /应用程序启动/路由图 /Global.asax /控制器/服务控制器.cs /视图/Services/

404错误
on
https://localhost:44300/services
当页面和路由存在时


问题 是什么导致了这个路由问题


注意到的意见 我不明白的是,目录中的内容是如何显示的,比如
https://localhost:44300/
&
https://localhost:44300/articles
是唯一有效的方法


GitHub项目


感兴趣的文件 /区域/物品/物品注册EA.cs /应用程序启动/路由图 /Global.asax /控制器/服务控制器.cs /视图/Services/index.cshtml /视图/服务/_Services.cshtml



如果您使用的是默认的ASP.NETMVC5项目,那么这可能是对您有用的信息。首先,RoutedBugger Nuget包是一个非常好的工具,即使在上次更新3年后也是如此。它轻而易举地指出了我的错误


全球.尽快 首先,请注意如何
AreaRegistration.RegisteralAreas()放在
RouteConfig.RegisterRoutes(RouteTable.Routes)之前。路由按其接收的路由配置的顺序优先。区域注册优先于RouteConfig


RouteConfig.cs和ArticleAreaRegistration.cs 接下来,
文章和投资组合区域
使用与

        // default route (last)
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

因此,由于ArticleArea注册先到,这两个之后的服务路由将不起作用。

您是否尝试使用RoutedBugger(nuget package)查看您预期的路由是否是路由实际到达的路由?我没有。我甚至都不知道这件事。我一直在使用CodeMaid和Web Essentials。我一定会查一查,看看有没有什么问题。我最大的问题是在没有错误消息的情况下修复某些东西。谢谢@KarenB!因为你,我得到了答案!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace JosephMCasey
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("images/{*pathInfo}");
            routes.IgnoreRoute("ckeditor/{*pathInfo}");

            // access TermsController/Index via /terms
            routes.MapRoute(
                name: "Terms",
                url: "terms",
                defaults: new { controller = "Terms", action = "Index" }
            );

            // access PrivacyController/Index via /privacy
            routes.MapRoute(
                name: "Privacy",
                url: "privacy",
                defaults: new { controller = "Privacy", action = "Index" }
            );

            // access ServicesController/Index via /services
            routes.MapRoute(
                name: "Services",
                url: "services",
                defaults: new { controller = "Services", action = "Index" }
            );

            // access ErrorController/NotFound via /404
            routes.MapRoute(
                name: "NotFound",
                url: "404",
                defaults: new { controller = "Error", action = "Index" }
            );

            // default route (last)
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace JosephMCasey
{
    public class MvcApplication : HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;

namespace JosephMCasey.Controllers
{
    //[Authorize]
    [AllowAnonymous]
    public class ServicesController : Controller
    {
        [AllowAnonymous]
        public ActionResult Index()
        {
            return View();
        }
    }
}
@section SPAViews {
    @Html.Partial("_Services")
}
@section Scripts{
    @*
        @Scripts.Render("~/bundles/knockout")
        @Scripts.Render("~/bundles/app")
    *@
}
@{
    ViewBag.Title = "Privacy";
    ViewBag.Keywords = "";
    ViewBag.Description = "";
    ViewBag.Created = "";
    ViewBag.Thumbnail = "";
    ViewBag.Image = "";
    ViewBag.TwitterCard = "";
    ViewBag.Site = "";
    ViewBag.URL = "";
    ViewBag.ImageHeight = "";
    ViewBag.ImageWidth = "";
    ViewBag.Site = "";
    ViewBag.Creator = "";
    ViewBag.OGType = "";
}
<section class="bg-lake light row shelve">
</section>
        // default route (last)
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );