Search code examples
asp.net-mvcasp.net-mvc-4directory-structurerenderpartialasp.net-mvc-partialview

MVC 4 solution structure Partial View


Well since most of the tutorials and demos chooses to put the partial view in shared folder im asking for a better way to do this.

My problem: I want to use partial views in order to create a dynamic interface with reusable views. As i can with usercontrols. Since there might be a lot of partial views i want to put them in a seperate folder than the shared folder.

example: How it looks today:

[View]

  • [View.Home]
    • index.cshtml
  • [View.Shared]
    • _layout.cshtml

A better way [View]

  • [View.Home]
    • index.cshtml
  • [View.Shared]
    • _layout.cshtml
  • [View.Shared.Partial]
    • partial1.cshtml
    • etc

Or should i rethink my approach enirely? if so how? if not what should i think about?


Solution

  • Here is an example of something I do,

    • Application Wide used partial views - I put them in my Shared directory.
    • Partial Views for a specific Controller - I put them in the Views/[ControllerName] Directory.