I set DI in my Controller as shown below and tied to register IHubContext as it seen on
Controller:
public class DemoController : Controller
{
private IHubContext<DemoHub> context;
public DemoController(IHubContext<DemoHub> context)
{
this.context = context;
}
}
Global.asax:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
BundleConfig.RegisterBundles(BundleTable.Bundles);
var container = new Container();
container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();
container.Register<IHubContext, IHubContext>(Lifestyle.Scoped);
// or
container.Register<IHubContext>(Lifestyle.Scoped);
// code omitted
}
But when I debug my app, encounter "System.ArgumentException: 'The given type IHubContext is not a concrete type. Please use one of the other overloads to register this type. Parameter name: TImplementation'" error. So, how can I register IHubContext properly?