jaekie
jaekie

Reputation: 2303

MVC Controller in DLL namespaces

Currently I have my Controllers and Views inside a separate DLL

When I create a new controller, I'm having to update my namespace to match how it is going to be in my web project.

I'd like my controllers with a different namespace, but if i change my namespace, I'm getting 404 errors..

I'll give an example..

I have a controller at

namespace MyWebSite.Web.Mvc.Areas.Member.Controllers
{
}

I'd like to change it to

namespace MyWebSite.DLL.Mvc.Areas.Member.Controllers
{
}

But this doesn't work.. How can I change my namespace and still have it work?

Upvotes: 1

Views: 360

Answers (1)

shawty
shawty

Reputation: 5829

As far as I'm aware in a bare bones MVC project, the mvc runtime will always default to the normal controller name space for that app beacuse of the coding to convention model that MVC uses.

However, thats not to say what your trying to attempt is not possible.

In order to use different namespaces, I think ideally you need to be looking at something like the MEF functionanlity built into .NET 4, or you need to be using an IOC container such as Unity/Structuremap or one of the many others available.

We have at least one presentation on lidnug about building MVC apps using building blocks, which can be found in the archves at:

http://lidnug.org/archives.aspx

and there's quite a few available on channel9.msdn.com from previous PDC and other ms dev conferences.

Upvotes: 1

Related Questions