0
私はいくつかのプロジェクトのうちの1つが認証のためのものです。しかし、私はCORS
設定を設定しましたが、それでもエラーを返します。プリフライトリクエストに対する応答がアクセスコントロールを通過しません(Angular 2 - Web API)
注: Web Apiアプリは郵便配達員で動作します。ここで
は、私がこれまで何をやったかである:
Startup.cs
[assembly: OwinStartup(typeof(LabelGenerator.Startup))]
namespace LabelGenerator {
public partial class Startup {
public void Configuration(IAppBuilder app) {
ConfigOAuth(app);
ConfigWebApi(app);
}
}
}
Startup.Auth.cs
namespace LabelGenerator {
public partial class Startup {
private void ConfigOAuth(IAppBuilder app) {
OAuthBearerAuthenticationOptions oAuthServerOptions = new OAuthBearerAuthenticationOptions();
// Token Generation
app.UseOAuthBearerAuthentication(oAuthServerOptions);
}
private void ConfigWebApi(IAppBuilder app) {
HttpConfiguration conf = new HttpConfiguration();
WebApiConfig.Register(conf);
app.UseWebApi(conf);
// CORS
app.UseCors(CorsOptions.AllowAll);
}
}
}
のWeb.config
これにprivate void ConfigWebApi(IAppBuilder app) {
HttpConfiguration conf = new HttpConfiguration();
WebApiConfig.Register(conf);
app.UseWebApi(conf);
// CORS
app.UseCors(CorsOptions.AllowAll);
}
:
<modules runAllManagedModulesForAllRequests="true">
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>