这是我的重设密码。我没有给出文件。我还添加了错误的图像。 Web配置文件中的密码。 image of the error 有人帮忙吗?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.Drawing;
public partial class ResetPassword_resetpassword : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string CS = ConfigurationManager.ConnectionStrings["RegisterDataConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("select * from userDataTable where email='"+TextBox1.Text+"'",con);
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
if(dt.Rows.Count != 0)
{
string myGUID =Guid.NewGuid().ToString();
int Uid = Convert.ToInt32(dt.Rows[0][0]);
SqlCommand cmd1 = new SqlCommand("insert into tblResetPasswordRequests values('"+myGUID+"','"+Uid+"',getdate())",con);
cmd1.ExecuteNonQuery();
string ToEmailAddress = dt.Rows[0][3].ToString();
string Username = dt.Rows[0][1].ToString();
string EmailBody = "hi "+Username+" <br/> click the link below to reset your password <br/>http://localhost/IISvirtualDirectory/mainProject/ResetPassword/changePassword.aspx?Uid="+myGUID ;
MailMessage PassRecMail = new MailMessage("mananchakma45@gmail.com",ToEmailAddress);
PassRecMail.Body = EmailBody;
PassRecMail.IsBodyHtml = true;
PassRecMail.Subject = "Reset Password";
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(PassRecMail);
}
else
{
Label1.Text = "There is no valid email ";
}
}
}
}
这个是我的web.config设置,虽然我没有给出密码
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
<add key="SendEmail" value="true" />
</appSettings>
<system.net>
<mailSettings>
<smtp from="mananchakma45@gmail.com">
<network host="smtp.gmail.com"
port="587"
userName="mananchakma45@gmail.com"
password=""
enableSsl="true"/>
</smtp>
</mailSettings>
</system.net>
</configuration>