YUI Developer
YUI Developer

Reputation: 385

Unable to deploy ASP.NET MVC 4 app as Azure Web Site

I have an ASP.NET MVC 4 app that I'm trying to deploy as an Azure Web Site. My app works fine in my local environment. When I publish the site to azure though, I receive the following error:

Multiple types were found that match the controller named 'Root'. This can happen if the route that services this request ('') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.

The request for 'Views' has found the following matching controllers:
MyApp.HD.Web.Controllers.RootController
MyApp.Web.Controllers.RootController

Why would I get this error on Azure but not locally? I can't figure out how to get around it.

Thank you

Upvotes: 0

Views: 425

Answers (1)

Paul Fleming
Paul Fleming

Reputation: 24526

I've had this problem before. Let me explain why it happened.

We added a new project to our solution, let's call it NewProject. This project had been set up incorrectly so we recreated it as NewProject2. Once the project was setup and working, we renamed it to NewProject. This is when the problem started. Under certain build configurations we were getting the same error as you. It was complaining about ambiguous controllers with namespaces NewProject and NewProject2. Doing a find-in-files returned no matches for NewProject2. The was thoroughly frustrating. Given that this was only occuring under certain build configurations was a big sign that the problem was with left-over references in the bin folder(s). Doing a clean didn't seem to fix the problem. The ultimate fix was to do a complete code purge. DLLs typically do not get committed to source control. I backed up and deleted all code and got it back from source control. The issue no longer occurs.

It's worth mentioning that this issue was not global. It only occurred on certain developer machines. I figure the ones that were affect were the ones that had gotten latest from source control during the process of create1/create2/rename2/delete1.

  1. Try doing a clean and rebuild in the affected build config.
  2. Try manually removing your bin and obj folders.
  3. Try a complete code purge

Upvotes: 1

Related Questions