MVC 3 Soulution organisation
I am trying to build an application using MVC 3, I know from the start that the application will be fairly com开发者_如何学运维plex with lots of different sections containing different areas of functionality.
What I am attempting to do is separate out this functionality into class libraries which include the views, I have set the build folder of the class library to an areas folder within the MVC application and copied a Razor view engine from Wayne Haffenden's blog post This has not worked at all.
I have also tried to use MEF which I can get to work using MVC2 but not MVC3. Does anyone have any suggestion of how I might accomplish this or even better a few examples where this has all ready been done.
Thanks.
You could try MvcContrib's portable areas that offer support for this. But in general I would agree with jfar that seperating an MVC project into different assemblies (that include views) is not easy right now.
I have a fairly large MVC 3 application (3 sites) in which I use Areas extensively. My controllers get all their data from repositories (referenced from another project) and I have another project called MyProject.Web.Shared which contains common code such as Attributes, Filters, Extensions, HtmlHelpers etc.
Although I have a little bit of code duplication in my views I feel it strikes a good balance between the DRY principle and extensibility, as I treat all my sites (and views) as individual entities as the needs within each site may change over time. I find that using Areas to separate separate functionality works really well.
精彩评论