ich signalR in Web Api bin Abbilden von folgendem Code in Startup.cs KlasseSignalR 403 Statuscode auf websocket Transport Handshake
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
app.Map("/signalr", map =>
{
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration
{
EnableDetailedErrors= true,
EnableJSONP=true
};
map.RunSignalR(hubConfiguration);
});
}
Zusammen mit ihm verwendet i Bearer-Token-Authentifizierung und Cookies Authentifizierung in Web Api durch folgenden Code
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
AuthenticationMode = AuthenticationMode.Active,
CookieHttpOnly = true,
CookieSecure = CookieSecureOption.SameAsRequest,
CookiePath = "/",
CookieDomain = "xxxx.cloudapp.net",
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
PublicClientId = "self";
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider(PublicClientId),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
AllowInsecureHttp = true,
};
app.UseOAuthBearerTokens(OAuthOptions);
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions()
{
Provider = new QueryStringOAuthBearerProvider("Token")
});
Web Api ist auf verschiedene Domain so i Cors für Api Anrufe aktiviert durch folgenden Code
public static void Register(HttpConfiguration config)
{
var cors = new EnableCorsAttribute("http://localhost:8080,http://www.myweb.com,http://myweb.com", "*", "*");
cors.SupportsCredentials = true;
config.EnableCors(cors);
......
......
}
Jetzt, während von Client-Seite verbinden, ich in der Konsole
folgende Störung erhalte istHier Antwort, dass ich in entsprechend websocket Handshake bin immer auf
Bitte führen Dies.
Vergewissern Sie sich, dass Sie in Ihrer Web API App (Server) einen WebSocket aktiviert/unterstützt haben. –
Es ist in Cloud-Service aktiviert –
nicht sicher, ob dies damit zusammenhängen, aber wenn Sie Framework 4.5 verwenden haben Sie in web.config> appSettings-Tag –
Patel