0

Keeping DRY with ASP.NET and multiple projects.

At the company I work for we are in the process of moving from Classic ASP to ASP.NET for our large intranet site.

There are currently two developers working with this intranet site at this time and we do not currently use any form of source control other than communicating to each other which projects we are currently working on. I’m not sure if we are going to get approval to use Team Foundation Server or any other source control system yet.

Our site currently consists of a mix of single static content and single dynamic content pages.

In addition there are approximately 50 different web applications all used by various departments throughout the company. These all range in complexity from single page forms all the way to very complex multiple page applications with various levels of report generating capabilities.

All of these web pages share a common layout, basic javascript, css, header, footer, and sidebar. I’d like to follow the DRY principles as much as possible to aid in redesigns or changes to the shared header, footer and sidebar.

My guess is that we will end up having a mix of HTML, Classic ASP, .NET Webforms and .NET MVC applications all housed on one server under the same domain name.

Goals:

  1. Master Pages / _Layout.cshtml - Share a single master page and an MVC layout page among the various webforms and/or MVC applications. I don’t mind having to maintain one master page for Webforms and a Layout page for MVC.
  2. Header, Footer, Sidebar - If I can’t easily share the Master/_Layout page. I want to share at least the header, footer and sidebar among all the various pages so they can easily be updated sitewide.
  3. Publishing changes for single applications - I’d rather not have to publish the entire site and all of the various applications every time I make a change to one of the applications. Is there a way to retain this functionality and still achieve goals 1 and/or 2?

If you can please tailor your answers for someone with almost no experience working with ASP.NET Webforms, MVC and C#. I have completed several tutorials but am still very much in the beginning stages of the learning process.

Thanks for any help that you can offer it is greatly appreciated.

2
  • 2
    Why do you need "approval" for source control? There are plenty of free source control tools out there that you can use. Subversion, Git, Mercurial, etc.. Commented Jul 12, 2012 at 18:11
  • I'm in a corporate environment and while we do already have the license for TFS we might not get the allocated server space to run a source control system. I am pushing hard to have source control as I do see the benefits but it's several layers of bureaucracy out of my direct control. Commented Jul 12, 2012 at 18:33

1 Answer 1

1

To achieve all three requirements you'd have to have your layouts in a separate project that will be common for all other your projects.

Take a look at this article, which explains how you can compile views into a dll. Once this is done, you'll be able to share this dll file between the rest of your applications, thus sharing layout pages, which will have header, footer and sidebar.

Put all your other MVC application in separate projects as well (You can still keep them all under a single solution), so that you can build and deploy them separately.

Sign up to request clarification or add additional context in comments.

4 Comments

If I keep all the projects in a single solution is it possible for me to still have multiple developers work on various parts without source control if that turns out to not be an option? Also if I do have to split them into separate solutions can I still share the compiled dll?
It does not really matter whether your projects are in the same our different solutions. As long as your developers work on different parts of the solution (or different parts of the same projects), there should not be any major problems. However, I still recommend using some sort of source control (TFS) as it really helps to merge the code in case there are conflicts. In case you end up splitting projects in separate solutions the dll file with common layouts still can be referenced by all of them.
I'm having some issues with Step 12 of the article you referenced. When I put in typeof(LogOnModel) I get a build error and I can't seem to figure out what I should be referencing there. Any suggestions?
step 12 out of 13... so close, man :) You probably did not include using to that new reference that you compiled. Try pressing Alt + Shift + F10 when you cursor is on LogOnModel. That should pop up a menu with available usings. Pick the PrecompiledViews one. If nothing is popping up when you press that combination, try writing using on the very top manually: @using [WhateveryourMVCSolutionName].PrecompiledViews;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.