我有同樣的問題:https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=4865,但我有模塊零核心模板的ABP v2.1。來自API而不是重定向的ABP 401響應
我使用Web.Mvc項目作爲我的啓動項目,我想進行API調用。
當我對API執行未經授權的請求時,我得到了「200 OK」響應而不是「401」。我在哪裏犯了一個錯誤?
我有同樣的問題:https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=4865,但我有模塊零核心模板的ABP v2.1。來自API而不是重定向的ABP 401響應
我使用Web.Mvc項目作爲我的啓動項目,我想進行API調用。
當我對API執行未經授權的請求時,我得到了「200 OK」響應而不是「401」。我在哪裏犯了一個錯誤?
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
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
確定你的函數沒有[AllowAnonomous]? – Worthy7
我想這是相同的https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2321 – hikalkan
嗨,謝謝,對不起,我錯過了這個問題,是的,這可能是同樣的問題。 –