Question

My problem is regarding setting up my app's access for internal users and external users.

Based on MS TechKB: AREAS in ASP.NET I went with AREAS. I have an Areas/Internal and Areas/External. Areas/External has the actual functionality and controllers for the app. All Areas/Internal does is check server variables and sets your identity as your domain name if it checks out in active directory.

The problem is, I can get to the Areas/External controllers/pages just fine but when I try to browse to the Areas/Internal area controller I get a 404. My controller is named Intranet (excluding the "Controller" in the name) and this is what my InternalAreaRegistration.cs file looks like:

    public override void RegisterArea(System.Web.Mvc.AreaRegistrationContext context)
    {
        context.MapRoute(
            "Internal_default",
            "Intranet/{action}/{id}",
            new { action = "Index", id = UrlParameter.Optional });
    }

    public override string AreaName
    {
        get
        {
            return "Internal";
        }
    }

Can anyone tell me why I would be getting a 404 on the internal controllers?

Was it helpful?

Solution

It seems you are missing controller segment after Area in the code you wrote above. It should be something like:

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Internal_default",
                "Intranet/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional },
                namespaces: new[] { "Your Controller Namespace" }
            );
        }

A related question at below link is answered, hope that will help too: Controller with same name as an area - Asp.Net MVC4

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top