Casey Crookston Casey Crookston - 1 year ago 74
C# Question

Copying Models, View, & Controllers to a new solution: Resource cannot be found

I have an Area (collection of models, views, and controllers) in one solution that I need to copy into another solution. I have replicate the file structure inside the target solution, along with all the models, controllers, helpers, web.config, etc. But, when I try to navigate to the view in a browser, I get:

404: The resource cannot be found.

With the exception of namespaces (to match the target solution) all files are identical (no mismatching controller action names, etc). I've checked the RouteConfig.cs file in both solutions, and they match. I've checked the global.asax file. The folder/file structure is identical:


In both solutions, this opens in debug to:


In the source solution, it renders the page. In the target solution, it throws the error.

What am I missing?

Answer Source

Without looking at the complete code of the broken solution it will be a long shot, but I guess you are missing the override RegisterArea in the new solution.

You should have a class called: NewAreaRegistration.cs under your NewArea folder like this:

public class NewAreaRegistration : AreaRegistration
        public override string AreaName
                return "NewArea";

        public override void RegisterArea(AreaRegistrationContext context)
                "NewArea", // Route name
                "NewArea/{action}/{id}", // URL with parameters
                new { controller = "NewArea", action = "Index"  } // Parameter defaults
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download