This project is read-only.

Using Separate Library Project for Controllers

Mar 31, 2014 at 7:11 PM
Hi,
Think along the lines of Separating Concerns, I have moved all of my Controller in my MVC4 solution into a Class Library of their own (I have always done this for my Model). Are there any known issues with this architecture when using T4MVC? I want to make sure that the controllers and views can discover each other. Any thoughts?

Thank you
Mar 31, 2014 at 10:23 PM
Hi Steve,

T4MVC currently can not look for controllers outside of the web project.

(it's written down as a known issue in the readme.txt: https://t4mvc.codeplex.com/SourceControl/latest#T4MVCHostMvcApp/T4MVC%20Files/readme.txt )

In my opinion moving the controllers away doesn't give you a lot of advantages. ASP.NET MVC is a presentation framework and controllers are very closely bound to views. I'd rather move my business logic services into separate assemblies and have the controllers call them. this should also keep your controllers small and should also match the separation of concerns pattern. But of course, this is just my opinion - there are many people with an opposite one ;)

best regards, christian
Apr 1, 2014 at 2:43 AM
Hi Christian,
Yes, I think I agree with what you stated- the benefits are small, and the headaches could be big. I actually think I did have it working- I had to change one of the settings and the MVC class was called something else when generated by the T4. I may revisit it later, but for now, it’s just too much work for too little gain.
Thanks