0

I have a new MVC4 app that I create off the MVC4 internet project template in VS11 beta. Now when I deploy the app to my web site hosting provider, and I leave the following line active in my Global.asax class, I get an error about MVC trying to register a route that already exists. When I comment out this line, everything runs fine, but action links to area specific controllers are broken, as I ask about in this question.

AreaRegistration.RegisterAllAreas();
Community
  • 1
  • 1
ProfK
  • 49,207
  • 121
  • 399
  • 775
  • Are you having a namespace collision in your routes? Meaning, are you declaring the proper namespaces in your route definition as in here ->http://haacked.com/archive/2010/01/12/ambiguous-controller-names.aspx – Tommy Jul 22 '12 at 23:56
  • If you comment out that line, area routing will fail as you have posted in your other question -> because you never registered the areas. You will need to figure out this issue and all 'should' be fine. Try with a simpler project or trim down your routing table to find the offending route. Namespaces are a big help with these issues as well (link from above) – Tommy Jul 22 '12 at 23:57

2 Answers2

1

If you have an old dll in your deployment bin directory (if you renamed your project or dlls at some point) then you'd get this error.

Make sure the bin directory is getting cleaned when you deploy.

jaminto
  • 3,895
  • 3
  • 32
  • 36
0

This usually happens when you have a controller in an area with the same name as a controller in your root website. i.e. "WebsiteNamespace.Controllers.HomeController" and "WebsiteNamespace.Areas.MyArea.Controllers.HomeController".

To rectify this, you need to declare namespaces on your base website routes:

        routes.MapRoute("Default", "{controller}/{action}/{id}", new {
            controller = "Home",
            action = "Index",
            id = UrlParameter.Optional
        }, new[] { "WebsiteNamespace.Controllers" });
Spikeh
  • 3,540
  • 4
  • 24
  • 49