我使用Owin自托管控制台应用程序建立了一个网站.我正在提供静态文件没有问题,网站静态部分的"根"正常工作,并且Web API路由也正常工作.
如果我浏览到:
http://localhost/index.html
Run Code Online (Sandbox Code Playgroud)
它呈现了我所期望的一切.但我还没弄清楚如何设置它以便浏览:
http://localhost
Run Code Online (Sandbox Code Playgroud)
提供index.html(作为默认视图).这是在IIS风格的网站下工作.如何使其与Owin自我主机一起使用?
我让SignalR与Angular客户端一起工作,但proxy.on()如果在订阅事件之前建立连接,我就无法工作.
我的服务器方法pushToClient在两个集线器上调用客户端方法.
var connection1 = $.hubConnection(); //Works fine since I started connection AFTER subscribing
var proxy1 = connection1.createHubProxy('clientPushHub');
proxy1.on('sendToClient', function (message) {
console.log('This will work: ' + message);
});
connection.start();
var connection2 = $.hubConnection(); // Doesn't work when I start the connection BEFORE subscribing
var proxy2 = connection2.createHubProxy('clientPushHub');
connection2.start();
proxy2.on('sendToClient', function (message) {
console.log('This will not work: ' + message);
});
Run Code Online (Sandbox Code Playgroud)
如果我改变了事情,以便proxy2在开始之前订阅pushToClient connection2,它可以正常工作.还尝试在start().done()回调中执行'on'订阅,但这不起作用.
我已经下载并验证了这个示例在连接后订阅时的预期效果,并且这篇ASP.NET文章/部分明确提到如果不使用生成的代理,您可以按此顺序执行操作,我没有.