示例#1
0
        void Application_Error(object sender, EventArgs e)
        {
            string ip = CommonStuff.GetLocalIPAddress(); // Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            Exception objErr = Server.GetLastError().GetBaseException();

            string objErrMgs = objErr.StackTrace;

            string err = "Error Date : " + DateTime.Now.ToString() + " , Error in: " + Request.Url.ToString() + " , Error Message:" + objErr.Message.ToString() + " ipaddress : " + ip;


            string path = HttpContext.Current.Server.MapPath("~/Logs/ErrorLog_GlobalErrors.txt");

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(path, true))
            {
                sw.WriteLine(err + objErrMgs);
                sw.WriteLine(objErr.StackTrace);
                sw.Close();
            }

            CommonStuff.SendEmail("*****@*****.**", "Error in DotNetIsEasy.com", objErr.Message.ToString() + "<br />IP: " + ip + "<br /><br />" + objErr.StackTrace);
            Server.ClearError();

            Response.Write(objErr.Message.ToString());
        }
        public ActionResult ResendEmail(LoginViewModel model)
        {
            UserMaster user = UserMaster.GetUserByEmail(model.Email, con);

            if (user == null)
            {
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }

            CommonStuff.SendEmail(model.Email, "Welcome to DotNetIsEasy.com", CommonStuff.getEmailVerificationBody(user.email, user.emailvalidationToken));
            return(RedirectToAction("Login", "Account"));
            //return View();
        }
        public ActionResult CreateUser(CreateUserViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.Password != model.ConfirmPassword)
            {
                ModelState.AddModelError("", "password and Confirm password doesnot match");
                return(View(model));
            }

            UserMaster user = UserMaster.GetUserByEmail(model.EmailAddress, con);

            if (user != null)
            {
                ModelState.AddModelError("", "Email already Registered");
                return(View(model));
            }

            string strp = UserMaster.EncryptString(model.Password);

            UserMaster new_user = new UserMaster();

            new_user.cid             = Convert.ToInt32(Session["cid"]);
            new_user.email           = model.EmailAddress;
            new_user.display_name    = model.DisplayName;
            new_user.hashed_password = strp;
            new_user.mobile_number   = model.Mobile;
            new_user.created_by_uid  = Convert.ToInt32(Session["uid"]);

            int i = UserMaster.CreateUser(new_user, con);

            if (i > 0)
            {
                user = UserMaster.GetUserByEmail(model.EmailAddress, con);
                CommonStuff.SendEmail(user.email, "Welcome to DotNetIsEasy.com", CommonStuff.getEmailVerificationBody(user.email, user.emailvalidationToken));

                //user = UserMaster.Login(model.EmailAddress, model.Password, con);

                //Session["uid"] = user.uid;
                //Session["DisplayName"] = user.display_name;
                //Session["cid"] = user.cid;
                return(RedirectToAction("Success", "Account"));
            }
            else
            {
                return(View(model));
            }
        }
        public ActionResult ForgotPassword(LoginViewModel model)
        {
            UserMaster user = UserMaster.GetUserByEmail(model.Email, con);

            if (user == null)
            {
                ModelState.AddModelError("", "Email is not registered with us.");
                return(View(model));
            }

            string rnd = CommonStuff.GetRandomString(30);

            UserMaster.GeneratePasswordToken(model.Email, rnd, con);
            CommonStuff.SendEmail(model.Email, "Reset your password", CommonStuff.getEmailPasswordReset(user.email, rnd));
            return(RedirectToAction("Success", "Account", new { msg = "A password reset link has been send on your email id.  Please check your spam folder if not deliver in inbox" }));
            //return View();
        }