我继承了一个项目,该项目在尝试在 .Net 4.0 项目中检索丢失的密码时给用户带来上述错误。我通过并找到了问题点,但问题是,生成的值似乎是正确的,所以我不知道为什么会发生错误。提前感谢任何可以查看以下代码并帮助我了解如何修复它的人。如果需要更多信息,请告诉我。我浏览了所有我能找到的东西,但没有任何线索能提供我可以使用的线索。问题是我无法追踪键/值组合应该输入的位置,我也不知道如何添加它。代码如下。
我在http://forums.asp.net/t/1926444.aspx/1?given+key+was+not+present+in+the+dictionary发表了类似的讨论,但没有人知道如何帮助我。
void EmailUser(User user)
{
user.ChangePasswordID = Guid.NewGuid();
user.Save();
MailMessage email = new MailMessage();
//problem line below
email.From = new MailAddress(Settings.LostPasswordEmailFrom);
email.To.Add(new MailAddress(uxEmail.Text));
email.Subject = Settings.LostPasswordSubject;
email.Body = EmailTemplateService.HtmlMessageBody(EmailTemplates.MembershipPasswordRecovery, new { Body = Settings.LostPasswordText, BeginRequired = "", EndRequired = "", UserName = user.Name, GUID = user.ChangePasswordID.ToString() });
email.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Send(email);
uxSuccessPH.Visible = true;
uxQuestionPanel.Visible = false;
uxUserInfoPanel.Visible = false;
uxUserNameLabelSuccess.Text = uxEmail.Text;
}
/// <summary>
/// The address that the lost password email will be sent from
/// </summary>
public static string LostPasswordEmailFrom
{
get
{
if (String.IsNullOrEmpty(SiteSettings.GetSettingKeyValuePair()["LA_MembershipProvider_lostPasswordEmailFrom"]))
return Globals.Settings.FromEmail;
return SiteSettings.GetSettingKeyValuePair()["LA_MembershipProvider_lostPasswordEmailFrom"];
}
}