public ActionResult Contact(ContactViewModel model) { if (!ModelState.IsValid) { return View(model); } if (DateTime.Now.ToUniversalTime() - model.RenderTime < TimeSpan.FromSeconds(3)) { return View(model); } try { var mailer = new Mailer(); mailer.SendMail(model.SendersName, model.SendersEmailAddress, "240 Hours", "*****@*****.**", "Message From Website", model.Body); } catch (SmtpException) { return View("ContactFailure"); } return View("ContactSuccess"); }
public ActionResult Contact() { var model = new ContactViewModel(); model.RenderTime = DateTime.Now.ToUniversalTime(); return View(model); }