I'm working on a controller that is a part of a very flat hierarchy of pages, and it looks like one section of the site could have over a dozen action methods, not including their corresponding post actions. Is there a good way to break this controller up while still preserving the section name? I don't want that controller class getting out of control.
If your controller class is getting out of control on a dozen actions, you might want to rethink how much logic should be in there and how much can be refactored out into services.
Also, if your controller is getting up to much more than a dozen actions, you might want to consider whether it can be broken down into separate controllers. Remember, you can change the routing rules and controller factory such that the URL remains the same but the controller is broken up.
If you're comfortable that you've done what you can and still want to break it into separate files - use a partial class.
If I understand correctly, you just want to split a class across multiple files so each file is easier to understand.
That would mean you want to use Partial Classes. They allow you to split the definition of a single class across multiple files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With