title: deploying global.asax to sharepoint 2010 in an enterprise environment to enable unity DI container
body: <p>Working on a SharePoint project I'm trying to use Unity as a dependency injection container.</p>
  
  <p>My first idea to get this container running is using the global.asax as described in the best practices by P&amp;P:</p>
  
  <p><a href="http://webclientguidance.codeplex.com/releases/view/17134#DownloadId=43305" rel="nofollow">http://webclientguidance.codeplex.com/releases/view/17134#DownloadId=43305</a></p>
  
  <p>In these best practices they tell you to manually edit the global.asax file to make it inherit SPUnityHttpApplication.</p>
  
  <pre><code>&lt;%@ Application Language="C#" Inherits="Unity.SharePoint.SPUnityHttpApplication" %&gt;
  </code></pre>
  
  <p>Manually editing this file is not an option in enterprise environments since we have multiple environments (DTAP) and all of them have multiple frontend servers that would need manual steps. </p>
  
  <p>I can't find any way to deploy a global.asax file by using a feature or wsp or anything because the global.asax is located in the web application root and sharepoint deploys other files to the /14 hive folder so you can't acces the web application root directory.</p>
  
  <p>Alternatives i've looked into is the <a href="http://msdn.microsoft.com/en-us/library/ff647574.aspx" rel="nofollow">SharePointServiceLocator</a>. this build in functionality does almost what i want. but it can only resolve classes that have a default constructor. this way i can't chain resolve all my implementations by using constructor injection. <a href="http://www.erwinvandervalk.net/2010/04/sharepointservicelocator-unity.html" rel="nofollow">I found a post</a> how to change the service locator to make use of unity but this doesn't seem to work properly if you read the comments. </p>
  
  <p>My problem can be fixed by fixing 1 of these 2 main problems:</p>
  
  <ul>
  <li>Don't arrange unity in the global.asax, but then where and how?</li>
  <li>Deploy the global.asax in sharepoint? possible?</li>
  </ul>