I have a large ASP.NET-MVC project and I have a lot of files in the shared View folder.
I want to group these files (Views) to make it easier to understand. I saw this blog post which seems to have the same issue but I would like to avoid an additional dependencies / dll in my solution.
Is there anyway to organize the Shared Views directory without any external dependencies. I am using the aspx View Engine (NOT Razor)
In ASP.NET MVC, sharing works in multiple ways.
1) Use the Controller's View Folder.
Yes, View Engine will always check you Shared folder for a partial view. But before checking the shared folder, the View Engine will check the "active" folder.
So to explain in better detail, take a scenario where you are using HomeController, rendering a View in the "Home" View folder, and you are rendering a Partial View called "NavPartial". Before checking your "Shared" folder for the Partial View, the View Engine will check your "Home" View folder first.
This means that if you need to re-use Partials within a Controller, you can pack them into that Controller's dedicated View Folder.
I find this approach convenient. I organize my project and Controller structure to take advantage.
2) Use Areas
If you use Areas, each Area has a dedicated "Shared" folder. This is again convenient if your functionality is local to that Area.
that is for what for asp.net mvc is , all can be customizable.
you can do things like this where your structure looks like

this is about displaying templates
to display use
@Html.Display("","Home/Managable",null)
Display is helper extension method that find the partial view and render..
if you want editor based then you can use Editor Templates and Extenstion method is Editor , EditorFor etc..
Example here is in Razor but same applies to aspx view engine also..
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