0

I've inherited a project in which I'm the fifth proverbial 'cook in the kitchen'. The project is too mature for extensive changes on my timeline, but I'm thinking I can at least get rid of some of the "where was that code again!?" issues I'm having.

All of the controllers are dumped in the same Controller folder, but there are enough with similiar names to be a bit cumbersome. Additionally some of these controllers are solely for partial views. The admin page for instance has its own controller, but each of the four tabs on its view have their own model/view/controller. What are some recommended approaches I should take to get this under control?

6
  • Sub folders in the controllers folder? Commented Nov 18, 2013 at 19:58
  • Thats where I'm wanting to go, but I seem to remember having issues with some of my tool sets recognizing associated models/views/controllers Commented Nov 18, 2013 at 20:03
  • You should keep everything that controller a view in the same controller. If you have multiple controllers for the same view, you are doing something wrong, and messing with the MVC Pattern. Commented Nov 18, 2013 at 20:04
  • I agree Fal, but I didn't start this project, and cant realistically change it at this juncture. To be clear though, each partial has a dedicated controller. The view only has one of its own. Though there is a controller being used as a business logic class in here too. Commented Nov 18, 2013 at 20:09
  • @MikeSchwartz The issue i'm having is the views can't be found by the controller if I do the corresponding subdirectory in the view folder Commented Nov 18, 2013 at 20:16

1 Answer 1

1

If you're looking to organize your MVC project, I find Areas an invaluable way to keep things from getting out of control.

It might mean changing some of your paths, but I'll leave it to you to determine the value to your particular project.

Have a read of this: http://msdn.microsoft.com/en-us/library/ee671793%28v=vs.100%29.aspx

Sign up to request clarification or add additional context in comments.

2 Comments

Before I dive into attempting to implement this, would it cause any interruptions to query strings? I don't see that it would but worth asking.
You can use the AttributeRouting table to make sure your paths don't change. The query strings don't care where the controllers are.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.