2017-03-20 30 views
0

我使用ASP.NET Core作爲API,並且無法找到配置標識的方式以返回401而不是重定向到登錄頁面。我使用IdentityServerAuthentication中間件。返回401而不是重定向標識服務器

在Startup.cs,我給這些選項:

 var options = new IdentityServerAuthenticationOptions 
     { 
      Authority = Configuration.GetConnectionString("Authority"), 
      ScopeName = "scopeName", 
      RequireHttpsMetadata = false, 

     }; 
     app.UseIdentityServerAuthentication(options); 
+0

你嘗試在IdentityServerAuthenticationOptions上設置AutomaticChallenge = false? –

+0

我試過了,並沒有解決問題。 – Astyan

+0

您是否嘗試在身份驗證中添加「AccessDeniedPath = new PathString(」/ Account/Forbidden /「)? –

回答

1

我找到一個解決方案, 在請求中,您可以添加頁眉X-要求,隨着使用XMLHttpRequest的價值。 這將告訴身份不重定向到登錄頁面。

+0

不適用於我,對不起。 –

相關問題