After namespace change “multiple types were found that match the controller named ‘X'”

I started work on a new MVC 5 project today and after working on it for a short while I decided I wanted to change the name of the web project to [ProjectName].WebUI from just [ProjectName].  So, I renamed the project, updated the project namespace and updated all my files to use the new namespace so my solution was now made up of [ProjectName].sln, [ProjectName].WebUI and [ProjectName].WebUI.Tests.  All good I thought, but then I went to debug it and got this message:

Multiple types were found that match the controller named ‘Home’. This can happen if the route that services this request (‘{controller}/{action}/{id}’) 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.

Continue reading

Allow dashes within urls using asp.net MVC 4

UPDATE: This applies to MVC 5 too

I was kind of surprised recently when I wanted to create an asp.net MVC view with dashes in it and found out that I couldn’t.

To me, reading-a-url-like-this is better than readingaurllikethis so I thought there must be a way to get around this. After all, web apps like WordPress and Umbraco allow this so why can’t I just do it in asp.net MVC?

After doing a bit of research on the subject I found out that I needed to do a couple of things Continue reading