Skip to content

Unity.WebAPI is a library that allows the simple integration of Microsoft's Unity IoC container with ASP.NET Web API.

License

Notifications You must be signed in to change notification settings

Illivion/Unity.WebAPI

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity.WebAPI

Unity.WebAPI is a library that allows the simple integration of Microsoft's Unity IoC container with ASP.NET Web API.

Getting started with Unity.WebAPI

The easiest way to add Unity.WebApi to your project is via the NuGet package. You can search for unity.webapi using the GUI or type the following into the package manager console in Visual Studio:

install-package Unity.WebApi

Once installed, just add a call to UnityConfig.RegisterComponents() in the Application_Start method of Global.asax.cs and the Web API framework will then use the Unity.WebAPI DependencyResolver to resolve your components.

e.g.

public class WebApiApplication : System.Web.HttpApplication
{
  protected void Application_Start()
  {
    AreaRegistration.RegisterAllAreas();
    UnityConfig.RegisterComponents();                           // <----- Add this line
    GlobalConfiguration.Configure(WebApiConfig.Register);
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
  }           
}  

Add your Unity registrations in the RegisterComponents method of the UnityConfig class. All components that implement IDisposable should be registered with the HierarchicalLifetimeManager to ensure that they are properly disposed at the end of the request.

More Information

You can find out more about what has changed in this release by visiting the FeedbackHound Blog.

About

Unity.WebAPI is a library that allows the simple integration of Microsoft's Unity IoC container with ASP.NET Web API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 76.7%
  • Pascal 22.6%
  • Batchfile 0.7%