I registered unity container like this:
var container = new UnityContainer();
container.RegisterType(new Containe
I'm assuming you're resolving some Controller instance using the container. If that's the case, you can have the controller receive the IUnityContainer as a dependency just like any other.
What are you trying to accomplish? Getting the container in your resolved classes is not great because it couples your classes with the container, and can usually be replaced with other mechanisms.
class Program
{
static void Main(string[] args)
{
var container = new UnityContainer();
var foo = container.Resolve();
}
}
public class MyController
{
private IUnityContainer container;
public MyController(IUnityContainer container)
{
this.container = container;
}
}