Can I configure MVC to directly look into a class library (“MyApp.Controllers” for example) instead of the foder Controllers?
Can I configure MVC to directly look into a class library (MyApp.Controllers for example)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, you can. The easiest way is to add the namespace of your class library to the
routers.MapRoutecall in global.asax. This is how one of our configurations look like:Notice that we use an overload of MapRoute that allows us to supply a string array of controller namespaces.
Another option is to implement a custom IControllerFactory, but that’s more work and usually not necessary.