Fabio Milheiro
Fabio Milheiro

Reputation: 8474

MVC 3: May I place the controllers in a dll?

It really doesn't matter, but there's a reason why I want the controllers in a DLL file.

May I do that in an MVC project?

Upvotes: 2

Views: 1726

Answers (3)

Tony John
Tony John

Reputation: 31

Make sure to modify the routes in global.asax, like this:

public static void RegisterRoutes(RouteCollection routes) { 
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");  
    routes.MapRoute( 
        name: "Default", 
        url: "{controller}/{action}/{id}",  
        defaults: new { 
            controller = "Home", 
            action = "Index", 
            id = UrlParameter.Optional 
        }, 
        namespaces: new[] {
            typeof(HomeController).Namespace 
        } 
    ); 
} 

Notice the additional namespaces argument to the MapRoute method.

Upvotes: 3

John Farrell
John Farrell

Reputation: 24754

Yes.

You don't have to do anything special.

Upvotes: 2

Bas
Bas

Reputation: 678

create a mvc project MvcApplication1.

create a mvc project MvcApplication2 and delete everything in it.

add reference to MvcApplication2 in MvcApplication1

create a HomeController inside MvcApplication2

create a view inside MvcApplication1

that's it.

Upvotes: 4

Related Questions