Lubudubu1010
Lubudubu1010

Reputation: 199

ASP.NET MVC Views/Controllers management

I'm working on a pretty big project, which have insane ammount of methods in each controller. Same with Views, one folder contains about 150 .cshtml files, what makes this hard to explore. I wanted to create separate folder for each part of window, but that changes my routing adress from ./Tavern/Shop to /Views/Tavern/Tavern/Shop. Tavern controller have 3000+ lines of code, and even with (Ctrl+F) its hard to find and edit some functionality.

Any ideas how can i improve this without changing many files in solution?

Upvotes: 0

Views: 284

Answers (1)

Ziv Weissman
Ziv Weissman

Reputation: 4556

It is hard to help without viewing your code but these should be your guidelines:

  1. Controllers should be as 'skinny' as possible, all the code should be done in your BL layer. (external lib)

  2. Controller should be very specific - i.e. product, contact, home, etc...

  3. The routing is done via the controller, and not the location of the view - you can specify on your return View("~/AnyPath/GoesHere/AndTheRouting/IsTheSame.cshtml") (it will be controller/action) (or however you defined it in the routing.config)

  4. You can consider working with Areas.

Upvotes: 2

Related Questions