Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6078629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:51:19+00:00 2026-05-23T10:51:19+00:00

Working on a SharePoint project I’m trying to use Unity as a dependency injection

  • 0

Working on a SharePoint project I’m trying to use Unity as a dependency injection container.

My first idea to get this container running is using the global.asax as described in the best practices by P&P:

http://webclientguidance.codeplex.com/releases/view/17134#DownloadId=43305

In these best practices they tell you to manually edit the global.asax file to make it inherit SPUnityHttpApplication.

<%@ Application Language="C#" Inherits="Unity.SharePoint.SPUnityHttpApplication" %>

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.

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.

Alternatives i’ve looked into is the SharePointServiceLocator. 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. I found a post how to change the service locator to make use of unity but this doesn’t seem to work properly if you read the comments.

My problem can be fixed by fixing 1 of these 2 main problems:

  • Don’t arrange unity in the global.asax, but then where and how?
  • Deploy the global.asax in sharepoint? possible?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:51:20+00:00Added an answer on May 23, 2026 at 10:51 am

    The global.asax doesn’t seem to be the best solution to do this because of the deployment issues described in the question.

    A viable solution is implementing this in a httpmodule

    The init method can be used to wire everything up since this is called when the sharepoint application starts.

    the httpmodule can be added in the web.config by a feature receiver

    This way there is no need to do tricks with the global.asax that is located in a directory you can’t deploy to with a feature and you have all the functionality and correct time to instantiate the DI container.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a SharePoint project that needs to use the Lists
All, I'm working on a SharePoint project, but this isn't a SharePoint-specific question per-se.
Currently I'm working on this project to create a SharePoint projects portal, but the
Say I'm working with Sharepoint (this applies to other object models as well) and
I'm working on some SharePoint web parts and I'm trying to make them as
I'm working on a SharePoint workflow, and the first step requires me to open
I'm working on a SharePoint 2010 project. We have a usercontrol to include all
I need it for a Sharepoint project I'm working on.
I am working on visual web parts. I created a sharepoint project in VS2010
I have deployed an SSRS 2008 R2 project into our SharePoint Integration. This worked

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.