我推測你在Identity v2.1中使用SignInManager
,因爲在UserManager
上沒有這樣的方法。
當您撥打SignInManaer.PasswordSignIn()
,經過多次檢查後,如果一切都成功,auth-cookie實際上並未設置;它只會在稍後發送HTTP回覆的時候才設置回調。
當您致電SignOut()
AuthenticationManager
檢查之前是否有登錄,但它也檢查登錄AuthenticationType
的類型是否與SignOut
的類型匹配。我猜你的登錄是使用不同的身份驗證類型來註銷。
有太多可能的方法,爲什麼這不起作用。如果不考慮整個解決方案,很難推斷出原因。
You can check out AuthenticationManager
from Owin in Katana Project請親自看看究竟出了什麼問題 - 該組件實際上由Identity用於在Owin中設置回調來創建(或刪除)auth-cookies。
我只能想到用這個爲簽出的:
AuthenticationManager.SignOut(
DefaultAuthenticationTypes.ExternalCookie,
DefaultAuthenticationTypes.ApplicationCookie,
DefaultAuthenticationTypes.TwoFactorCookie,
DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie,
DefaultAuthenticationTypes.ExternalBearer);
從一切登出。只是可以肯定 - )
這可能是什麼使用? – Stilgar 2014-09-13 19:24:49
'if(!mycondition)等待_userManager.PasswordSignin(...)'如何? – trailmax 2014-09-13 20:43:35
@trailmax,現在我正在做同樣的事情。但問題是,爲什麼它不起作用。 – user960567 2014-09-14 05:37:39