Hi,
Am trying to generate random number and pass it from class a to class b with session
Class A
public static void SendPwd(string Email)
{
using (var client = new SmtpClient())
{
using (var message = new MailMessage(EmailFrom, Email))
{
Random rnd = new Random();
var random = rnd.Next();
if (random != null)
{
System.Web.HttpContext.Current.Session["random"] = random;
}
message.Subject = "Please Verify Your Account";
message.Body = "
Dear " + Email +
",
Please note the random Number and type in the Text box
" + "Your Random Number is
" + random + "
Best regards,
Team
Do not forward "
+ "this email. The verify link is private.";
message.IsBodyHtml = true;
client.EnableSsl = true;
client.Send(message);
};
};
}
Class B
var password = con.tblEmployees.Where(a => a.Emp_Email == user.EmailId).FirstOrDefault();
password.Emp_TempPwd = (int)HttpContext.Current.Session["random"];
con.SaveChanges();
return "success";
while am doing this I got this error
An exception of type 'System.NullReferenceException' occurred in ServerControl.dll but was not handled in user code
I have searched in Google to find it but I can’t find solution so kindly help me to solve this issue
thanks in advance
Francis SusaimichaelPosted Jun 29, 2016, 5:20 AM
Laalu ArPosted Jun 29, 2016, 2:42 AM
Francis SusaimichaelPosted Jun 29, 2016, 2:03 AM