7 articles and counting

Web App within a Web App – Build an Onion!

Sometimes you don’t always have total control of the web site or web application project you’re working with and you have a need to insert or extend the existing project.  Or perhaps you’ve inherited a project that was coded so horribly wrong you can’t easily make a needed update without first expending time you don’t have doing .NET project triage.   (Such is the case many times when designers try to play application developer)

Or perhaps you’ve got a need to use some new .NET functionality within a project that you can’t upgrade.  IE, you need to do something using .NET 3.5 but the site you have to use is based on .NET 2.0.  

Looks like you may need to build an Onion – just add layers :)

Such was the case for me the other day.  I had a corporate .Net 2.0 website that was hosted on a domain that I needed to publish a 3.5 web application project to and I didn’t have the level of source control I needed to seamlessly nest my project within the existing project.  (The existing project also had some issues due to the way the developers manage their source however that is an article for another day)

Since I couldn’t nest my new project within the existing one I decided to create a new web app type project and publish to a new directory within the existing project.  I needed my new project to have it’s own web.config and bin directory.

This actually turned out to be quite easy, here’s what you do.

  1. Create your New Web Application Project
  2. Modify your new web.config to play nice within it’s parent project
    1. Comment out the <configSections> element.  If you leave this element in you’ll get some fun errors about settings already being specified.  Why?  Because the parent web.config likely already has a <configSections> element.
      1. If you’d like to read about <configSections> check out the page on MSDN, talking about it here is outsite the scope of this post. 
    2. Comment out the ScriptModule key in the <httpModules> element.
  3. Publish your project to the target folder within the parent project

That’s it, not too bad.  The new project will use it’s web.config and it’s bin folder independent of the parent project – yes, even though it may be a different version of the framework

But Wait – There’s a Catch. 

If your situation was like mine and you need to roll something out quickly inside of a larger project that you don’t totally control your new web app could be at risk.  If the parent project is re-published and during publishing the user chooses to do delete remote files your web app will be deleted since it’s not part of the parent project.

Leave a Reply

Name (required)
Mail (will not be published) (required)

Your Comments:

Spam Protection by WP-SpamFree