unitycontainer / aspnet-webapi

Unity.AspNet.WebApi package
Apache License 2.0
9 stars 11 forks source link

missing PerRequestLifetimeManager in Unity.AspNet.WebApi #10

Open laksh-parab opened 6 years ago

laksh-parab commented 6 years ago

When using Unity with ASP.NET Web API project i added the following packages

  <package id="Unity" version="5.8.5" targetFramework="net471" />
  <package id="Unity.Abstractions" version="3.3.0" targetFramework="net471" />
  <package id="Unity.AspNet.WebApi" version="5.0.13" targetFramework="net471" />
  <package id="Unity.Container" version="5.7.0" targetFramework="net471" />
  <package id="WebActivatorEx" version="2.2.0" targetFramework="net471" />

However, I can not use PerRequestLifetimeManager because it is not part of Unity.AspNet.WebApi. Instead PerRequestLifetimeManager is part of Unity.Mvc. and when Unity.Mvc Nuget package is added to Web Api Project it brings in other Web UI related dependencies like

Microsoft.AspNet.Razor
Microsoft.AspNet.WebPages
Microsoft.AspNet.Mvc

Is there a way to use PerRequestLifetimeManager in ASP.NET Web API without adding Unity.Mvc package?

ENikS commented 6 years ago

Just copy implementation of the manager and use it in your code.