title: Cannot get dependencys injected into Signalr Hub Using Autofac
body: <p>How do I get Autofac to inject dependencies into the signalr hubs, I have tried all the only questions many of which are now out of date, I have tried the signalr.autofac download from their site, but nothing seems to work?</p>
  
  <p>My Autofac</p>
  
  <pre><code>var builder = new ContainerBuilder();
  builder.RegisterControllers(typeof(MvcApplication).Assembly);
  
  //Register Context
  builder.Register(c =&gt; new myContext()).As&lt;IUnitOfWork&gt;().InstancePerLifetimeScope();
  
  //Repositories
  builder.RegisterGeneric(typeof(BaseRepository&lt;&gt;)).As(typeof(IBaseRepository&lt;&gt;)).InstancePerHttpRequest();           
  
  //Service Layer
  builder.RegisterType&lt;UserService&gt;().As&lt;IUserService&gt;().InstancePerHttpRequest();
  
  //other services etc
  
  builder.RegisterType&lt;ChatHub&gt;(); 
  
  var container = builder.Build();           
  
  DependencyResolver.SetResolver(new AutofacDependencyResolver(container));          
  
  GlobalHost.DependencyResolver = new Autofac.Integration.SignalR.AutofacDependencyResolver(container);
  RouteTable.Routes.MapHubs();
  </code></pre>
  
  <p>The dependency revolver I get from the autofac web site;</p>
  
  <p><a href="http://code.google.com/p/autofac/downloads/detail?name=Autofac.SignalR.3.0.0.zip" rel="nofollow">http://code.google.com/p/autofac/downloads/detail?name=Autofac.SignalR.3.0.0.zip</a></p>
  
  <p>but I get;</p>
  
  <blockquote>
    <p>No scope with a Tag matching 'AutofacWebRequest' is visible from the
    scope in which the instance was requested. This generally indicates
    that a component registered as per-HTTP request is being requested by
    a SingleInstance() component (or a similar scenario.) Under the web
    integration always request dependencies from the
    DependencyResolver.Current or ILifetimeScopeProvider.RequestLifetime,
    never from the container itself.</p>
  </blockquote>