我尝试使用带有autofac的SignalR Cross Domain。 我在其他领域使用它并没有成功。
这是我的代码:
public class Startup
{
public void Configuration(IAppBuilder app)
{
SetAutofacContainerSignalR(app);
}
private void SetAutofacContainerSignalR(IAppBuilder app)
{
var builder = new ContainerBuilder();
// STANDARD SIGNALR SETUP:
// Get your HubConfiguration. In OWIN, you'll create one
// rather than using GlobalHost.
var config = new HubConfiguration();
// Register your SignalR hubs.
builder.RegisterHubs(Assembly.GetExecutingAssembly());
//All builder.RegisterType
// Set the dependency resolver to be Autofac.
var container = builder.Build();
config.Resolver = new AutofacDependencyResolver(container);
// OWIN SIGNALR SETUP:
// Register the Autofac middleware FIRST, then the standard SignalR middleware.
app.UseAutofacMiddleware(container);
//app.MapSignalR("/signalr", config);
app.Map("/signalr", map =>
{
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = config;
map.RunSignalR(hubConfiguration);
});
}
}
这是我认为我必须改变的行
var hubConfiguration = config;
我该怎么做?