我創建了一個新用戶,批准它們,然後立即嘗試使用我剛創建用戶 ...的憑據對進行身份驗證,並將Authenticate方法返回「false」。爲什麼我可以創建一個新用戶,但是當我立即嘗試使用他們的憑證進行身份驗證時,我失敗了?
string username = "me";
string password = "mypassword";
string email = "[email protected]";
Membership.CreateUser(username, password, email);
currentUser = Membership.GetUser(username);
currentUser.IsApproved = true;
bool isAuthenticated = FormsAuthentication.Authenticate(username, password);
我檢查了數據庫表 - 使用該用戶名,密碼和電子郵件創建用戶。根據數據庫表,他們被批准。
但是,Authenticate方法仍然返回false。
這很奇怪。我們假設,您確實有其他用戶並非是即時創建的,並且可以登錄。您以這種方式創建的新用戶可以以後登錄嗎? – DOK 2009-12-11 18:11:26
當您在Visual Studio中運行(使用IIS或Cassini?)時,或者當您從Web服務器運行它時,會發生這種情況嗎? – DOK 2009-12-11 18:12:28