我一直试图让一个JavaScript信号客户端对抗asp.net web api。我收到以下错误。
Error: Error during negotiation request.
at Object.error (jquery.signalR-2.2.0.js:178)
at onFailed (jquery.signalR-2.2.0.js:644)
at Object.error (jquery.signalR-2.2.0.js:664)
at j (jQuery-2.1.4.js:2)
at Object.fireWith [as rejectWith] (jQuery-2.1.4.js:2)
at x (jQuery-2.1.4.js:4)
at HTMLScriptElement.c (jQuery-2.1.4.js:4)
at HTMLScriptElement.dispatch (jQuery-2.1.4.js:3)
at HTMLScriptElement.r.handle (jQuery-2.1.4.js:3)
以下是web api startup.cs
文件
[assembly: OwinStartup(typeof(HBSWebAPI.Startup))]
namespace HBSWebAPI
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
以下是JavaScript代码
var connection = $.hubConnection("http://192.168.100.162:80/HBSWebAPICopy", { logging: true, useDefaultPath: false });
var hub = connection.createHubProxy("RateCheckerHub");
connection.start({ withCredentials: false,jsonp: true })
.done(function () {
console.log('connected');
hub.say("success?");
})
.fail(function (a) {
debugger
console.log('not connected'+a);
});
});
`