2017-07-17 229 views
0

我有同樣的問題:https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=4865,但我有模塊零核心模板的ABP v2.1。來自API而不是重定向的ABP 401響應

我使用Web.Mvc項目作爲我的啓動項目,我想進行API調用。

當我對API執行未經授權的請求時,我得到了「200 OK」響應而不是「401」。我在哪裏犯了一個錯誤?

enter image description here

+0

確定你的函數沒有[AllowAnonomous]? – Worthy7

+1

我想這是相同的https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2321 – hikalkan

+0

嗨,謝謝,對不起,我錯過了這個問題,是的,這可能是同樣的問題。 –

回答

0

authorization文檔會給你每一個細節。

+0

儘管這個鏈接可能回答這個問題,但最好在這裏包含答案的重要部分,並提供供參考的鏈接。如果鏈接頁面更改,則僅鏈接答案可能會失效。 – aaron

2

ASP.NET 1.x的核心

ABP版本2.x /模塊零核模板V2.X

修改IdentityRegistrar。核心項目:

// Before 
services.AddAbpIdentity<Tenant, User, Role>() 

// After 
services.AddAbpIdentity<Tenant, User, Role>(options => 
{ 
    options.Cookies.ApplicationCookie.AutomaticChallenge = false; 
}) 

參考:https://github.com/aspnet/Security/issues/804

ASP.NET Core 2.0

ABP 3.x版/模塊零核模板V3.0.0 - v3.4.0

修改AuthConfigurer.Web.Mvc/.Web.Host項目:

// Before 
services.AddAuthentication() 

// After 
services.AddAuthentication(options => 
{ 
    options.DefaultAuthenticateScheme = "JwtBearer"; 
    options.DefaultChallengeScheme = "JwtBearer"; 
}) 

參考:92b6270 in module-zero-core-template v3.5.0

相關問題