我在远程服务器上的SignalR方法中有以下代码:
string connectionString = "Data Source=xxx.eee.eee.sss.com\sql01,1433;Initial Catalog=dbname;Integrated Security=SSPI";
using (SqlConnection connection = new SqlConnection(connectionString)) {
//throws error when IE calls but not from chrome
//Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
connection.Open();
...
}
的Web.config:
<configuration>
<configSections></configSections>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<customErrors mode="Off" />
<authentication mode="Windows" />
<identity impersonate="true" />
</system.web>
IIS 7安装程序:
Authentication: Only two Enabled (everyone else disabled)
1. ASP.NET Impersonation
2. Windows Authentication
C#SignalR代码:
[assembly: OwinStartup(typeof(mynamespace.Startup))]
namespace mynamespace {
public class Startup {
public void Configuration(IAppBuilder app) {
app.Map("/signalr", map => {
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration {
// EnableJSONP = true
};
hubConfiguration.EnableDetailedErrors = true;
map.RunSignalR(hubConfiguration);
});
GlobalHost.HubPipeline.RequireAuthentication();
}
}
}
客户端JavaScript代码:
function getData(caller, callback, cmdType, cmdText, args) {
var connection = $.hubConnection(Globals.DatabaseLocation + Globals.RequestApplicationPath.replace('/', '') + "/");
connection.logging = true;
var Hub = connection.createHubProxy('SignalR');
connection.start()
.done(function () {
Hub.invoke("GetData", cmdType, cmdText, args)
.done(processJSON)
.fail(function (error) {/*...*/ });
})
.fail(function (error) {/*...*/ });
function processJSON(message) {/*...*/ };
}
我被困在这一段时间,我会非常感谢任何帮助。
更新
我做了一些更多的调查:我有3个其他开发人员在chrome,IE10和IE11测试,但没有任何错误。上面概述的身份验证和模拟设置适用于所有人进行跨域调用并获取其数据。我是唯一一个得到错误的人,我只是在IE中得到它。 Chrome适合我。