// GET: Userpage
        public ActionResult userPage(User U)
        {
            if (U == null)
            {
                using (DataBaseEntities db = new DataBaseEntities())
                {
                    db.Users.Add(U);
                    db.SaveChanges();
                    ModelState.Clear();
                    U = null;
                    ViewBag.Message = "Registration Done";
                }
            }

            return(View(U));
        }
        public ActionResult Register(User U)
        {
            if (ModelState.IsValid)
            {

                using (DataBaseEntities db = new DataBaseEntities())
                {

                    //U.salt = crypto.generatesalt();
                    //U.password += U.salt;
                    //U.password = crypto.hashpassword(U.password);

                    //db.users.add(U);
                    //db.savechanges();
                    //modelstate.clear();

                    MailMessage m = new MailMessage();
                    SmtpClient sc = new SmtpClient();
                    try
                    {
                        m.From = new MailAddress("*****@*****.**");
                        m.To.Add(U.EmailID);
                        m.Subject = "Confirm";
                        m.IsBodyHtml = true;
                        m.Body = "Click http://localhost:53460/Account/confirmemail finish registration!";
                        sc.Host = "smtp.gmail.com";
                        sc.Port = 587;
                        sc.Credentials = new System.Net.NetworkCredential("*****@*****.**", "burrisislove");

                        sc.EnableSsl = true;
                        sc.Send(m);
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.Message);
                    }

                    //

                    U = null;
                    ViewBag.Message = "Registration Done";
                }
            }
            return RedirectToAction("Index" , "Home");
        }
Beispiel #3
0
        public ActionResult Register(User U)
        {
            if (ModelState.IsValid)
            {
                using (DataBaseEntities db = new DataBaseEntities())
                {
                    //U.salt = crypto.generatesalt();
                    //U.password += U.salt;
                    //U.password = crypto.hashpassword(U.password);

                    //db.users.add(U);
                    //db.savechanges();
                    //modelstate.clear();

                    MailMessage m  = new MailMessage();
                    SmtpClient  sc = new SmtpClient();
                    try
                    {
                        m.From = new MailAddress("*****@*****.**");
                        m.To.Add(U.EmailID);
                        m.Subject      = "Confirm";
                        m.IsBodyHtml   = true;
                        m.Body         = "Click http://localhost:53460/Account/confirmemail finish registration!";
                        sc.Host        = "smtp.gmail.com";
                        sc.Port        = 587;
                        sc.Credentials = new System.Net.NetworkCredential("*****@*****.**", "burrisislove");

                        sc.EnableSsl = true;
                        sc.Send(m);
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.Message);
                    }

                    //

                    U = null;
                    ViewBag.Message = "Registration Done";
                }
            }
            return(RedirectToAction("Index", "Home"));
        }