public ActionResult Register(RegisterModel RegisterModel, string returnUrl)
{
if (ModelState.IsValid)
{
// Attempt to register the user
MembershipCreateStatus createStatus;
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
Byte[] Password = encoding.GetBytes(RegisterModel.Password);
var EncryptedPass = MembershipProvider.EncryptPassword(Password);
Membership.CreateUser(RegisterModel.UserName, RegisterModel.Password, RegisterModel.Email, null, null, true, null, out createStatus);
if (createStatus == MembershipCreateStatus.Success)
{
FormsAuthentication.SetAuthCookie(RegisterModel.UserName, false /* createPersistentCookie */);
return Redirect(returnUrl ?? Url.Action("Index", "Education"));
}
else
{
ModelState.AddModelError("", ErrorCodeToString(createStatus));
}
}
// If we got this far, something failed, redisplay form
return View(RegisterModel);
}
嘗試使用EncryptPassword方法將其存儲在數據庫之前對密碼進行加密,然後Dycrypt它MembershipProvider.DecryptPassword方法,但得到時錯誤「因爲它的保護水平是無法訪問」 a'由於其保護級別'錯誤警告而無法訪問。獲取嘗試使用MembershipProvider.EncryptPassword
需要查看更多代碼才能告訴您發生了什麼。它與您嘗試訪問的私人或內部成員有關。 – awright18