MVC 4 Bereich Routing nicht funktioniert

Erstellte ich ein leeres MVC4-Anwendung, die alle Dinge funktionieren, nach, dass ich eine Fläche, um mein Projekt mit dem Namen "Moderator". Mein Bereich routing-code ist wie folgt:

using System;
using System.Web.Mvc;

namespace EskimoArt.Areas.Moderator
{
    public class ModeratorAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Moderator";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Moderator_default",
                "Moderator/{controller}/{action}/{id}",
                new {controller="Dashboard", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}

Und mein Global.asx-code ist wie folgt:

using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace EskimoArt
{
    //Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    //visit http://go.microsoft.com/?LinkId=9394801
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
    }
}

Aber jetzt möchte ich den Zugriff auf die

> http://localhost/Moderator/Dashboard

Zeigt es eine Fehlermeldung wie diese

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /Moderator

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
  • Hast du irgendwelche Controller in Ihrem Bereich?
  • Ja, ich habe controller in Meiner Gegend. Ich habe das problem herausfinden, indem Sie unter option die ist, dass Gerade call-AreaRegistration.RegisterAllAreas(); vor deine default-Route
  • Lesen Sie weiter unten - überprüfen Sie den namespace der controller(s)
InformationsquelleAutor Waqas Idrees | 2013-10-08
Schreibe einen Kommentar