簡體   English   中英

在ASP.NET MVC中處理錯誤的URL

[英]Handling Bad URLs in ASP.NET MVC

我正在使用Areas開發ASP.NET MVC。 我有三個區域。 但是,默認路由不是區域。 運行應用程序時,出現以下錯誤:

Areas_error

路線如下所示:

RouteConfig

        public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            namespaces: new string[] { "SmartSIMS.Web.Controllers" }
        );
    }

這些區域是:

  1. 管理

      public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( name: "Administration_default", url: "Administration/{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }, namespaces: new string[] { "SmartSIMS.Web.Areas.Administration.Controllers" }); } 
  2. 學生們

      public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( name: "Students_default", url: "Students/{controller}/{action}/{id}", defaults: new { action = "Index", id = UrlParameter.Optional }, namespaces: new string[] { "SmartSIMS.Web.Areas.Students.Controllers" }); } 
  3. 教師

      public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( name: "Teachers_default", url: "Teachers/{controller}/{action}/{id}", defaults: new { action = "Index", id = UrlParameter.Optional }, namespaces: new string[] { "SmartSIMS.Web.Areas.Teachers.Controllers" }); } 

如何解決此錯誤? 請協助。

問題已解決。 我將web.config中的RouteDebugger設置為false。 非常感謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM