Click here to Skip to main content
15,905,028 members
Home / Discussions / C#
   

C#

 
Questionwhy not escape to catch an error when i next run? Pin
Member 245846723-Feb-17 2:18
Member 245846723-Feb-17 2:18 
AnswerRe: why not escape to catch an error when i next run? Pin
OriginalGriff23-Feb-17 2:40
mveOriginalGriff23-Feb-17 2:40 
GeneralRe: why not escape to catch an error when i next run? Pin
Member 245846723-Feb-17 16:08
Member 245846723-Feb-17 16:08 
GeneralRe: why not escape to catch an error when i next run? Pin
OriginalGriff23-Feb-17 20:35
mveOriginalGriff23-Feb-17 20:35 
GeneralRe: why not escape to catch an error when i next run? Pin
Member 24584672-Mar-17 16:03
Member 24584672-Mar-17 16:03 
AnswerRe: why not escape to catch an error when i next run? Pin
Eddy Vluggen23-Feb-17 2:43
professionalEddy Vluggen23-Feb-17 2:43 
QuestionVS c# 2015 Setup Project: How to force Rollback before commit on my own condition Pin
nemo1423-Feb-17 1:07
nemo1423-Feb-17 1:07 
AnswerRe: VS c# 2015 Setup Project: How to force Rollback before commit on my own condition Pin
OriginalGriff23-Feb-17 1:22
mveOriginalGriff23-Feb-17 1:22 
AnswerRe: VS c# 2015 Setup Project: How to force Rollback before commit on my own condition Pin
Bernhard Hiller23-Feb-17 21:39
Bernhard Hiller23-Feb-17 21:39 
QuestionC# Winform: Slide show is not working when i use Quartz.net to fire my routine at specific time Pin
Tridip Bhattacharjee22-Feb-17 23:01
professionalTridip Bhattacharjee22-Feb-17 23:01 
AnswerRe: C# Winform: Slide show is not working when i use Quartz.net to fire my routine at specific time Pin
Pete O'Hanlon22-Feb-17 23:32
mvePete O'Hanlon22-Feb-17 23:32 
AnswerRe: C# Winform: Slide show is not working when i use Quartz.net to fire my routine at specific time Pin
Gerry Schmitz23-Feb-17 9:44
mveGerry Schmitz23-Feb-17 9:44 
QuestionSpell checker for c# project Pin
Ramesh Tigapuram21-Feb-17 22:14
Ramesh Tigapuram21-Feb-17 22:14 
AnswerRe: Spell checker for c# project Pin
Richard MacCutchan21-Feb-17 23:18
mveRichard MacCutchan21-Feb-17 23:18 
AnswerRe: Spell checker for c# project Pin
Pete O'Hanlon21-Feb-17 23:19
mvePete O'Hanlon21-Feb-17 23:19 
QuestionSea trying to change the RichTextBox does not work ? Pin
Member 245846721-Feb-17 18:59
Member 245846721-Feb-17 18:59 
AnswerRe: Sea trying to change the RichTextBox does not work ? Pin
Pete O'Hanlon21-Feb-17 21:27
mvePete O'Hanlon21-Feb-17 21:27 
QuestionPrinting arabic from epson TM-T88V VB.NET, C# Pin
aliraza156721-Feb-17 2:02
professionalaliraza156721-Feb-17 2:02 
AnswerRe: Printing arabic from epson TM-T88V VB.NET, C# Pin
Jochen Arndt21-Feb-17 2:48
professionalJochen Arndt21-Feb-17 2:48 
AnswerRe: Printing arabic from epson TM-T88V VB.NET, C# Pin
tiochus23-Feb-17 22:26
tiochus23-Feb-17 22:26 
QuestionVerify Email problem with AdminControler.cs Pin
John Nederveen20-Feb-17 9:08
John Nederveen20-Feb-17 9:08 
Hello to everybody,

I have been struggling now for days on a part of the code i'am working on. And can not find the problem. Explain; If i make a new user on my admin panel everything goes well (It insert in the database), but wenn it comes to the 'verification email' it does not send it to the new user. I can verify manual the database (set 0 to 1), but that is not the way it should be. Strange is that if a user 'forgot' his password yes it is sending the new password with a verification link. I hope someone can help me out. Thanks in advance,

Here is a part off the code;

C#
public ActionResult AddUser()
        {
            return View();
        }

        public ActionResult AddUserToDB(string name, string email, string pass, string level, string mode)
        {
            var lvl = (UserManager.Level)Enum.Parse(typeof(UserManager.Level), level);
            var md = (UserManager.Mode)Enum.Parse(typeof(UserManager.Mode), mode);

            UserManager.User user = new UserManager.User();
            user.Name = name;
            user.Email = email;
            user.Password = PasswordHash.CreateHash(pass);
            user.Level = lvl;
            user.Mode = md;
            user.ResetCode = "test";
            user.ResetCodeUsed = false;
            user.CreatedOn = DateTime.Now;
            user.SignIP = "";
            user.LastIP = "";
            user.Status = UserManager.Status.Active;
            if (user.Level == UserManager.Level.Agency)
            {
                user.Level = UserManager.Level.Elite;
                user.Mode = UserManager.Mode.Agency;
            }
            UserManager.AddUser(user);

            return RedirectToAction("Users");
        }
        [HttpPost]
        public PartialViewResult UserSorting(string keyword, string icon, int page = 1)
        {
            ViewData["users"] = UserManager.GetUsers(page, ADMIN_LIMIT, keyword, icon);
            int count = UserManager.GetUsersCount();

            ViewBag.TotalItems = count;
            ViewBag.PageLimit = ADMIN_LIMIT;
            ViewBag.CurrentPage = page;
            ViewBag.urlExpression = "/admin/users?keyword={0}&icon={1}&page={2}";
            ViewBag.Sort = icon;
            ViewBag.SortBy = keyword;
            return PartialView("~/Views/Partials/_users.cshtml");
        }

        //public ActionResult SignUp()
        //{
        //    TempData["Name"] = "";
        //    TempData["Email"] = "";
        //    return View("Signup");
        //}

        public ActionResult SignUp()
        {
            int u = Convert.ToInt32(TempData["user"]);
            TempData.Keep();
            if (u > 0)
            {
                return View("SignUp");
            }
            else
            {
                return PartialView("login");
            }
        }

        [HttpPost]
        public ActionResult SignUp(string name, string email, string password, string confirmpass, string level)
        {

            List<string> errors = new List<string>();
            // User don't need to fill long email address and name again and again.
            TempData["Name"] = name;
            TempData["Email"] = email;

            bool exist = UserManager.IsUserExisting(email.ToLower());
            if (exist)
            {
                ViewBag.Errors = new List<string>() {
                    "This email exists in our records,  please click <a href='/user/signin'>here</a> to login with this credentials."
                };
                return View();
            }

            ClickModels.UserManager.User user = new ClickModels.UserManager.User();

            //Put Validation here

            //Create the new user
            user.Name = name;
            user.Email = email;
            user.Password = PasswordHash.CreateHash(password);
            user.Level = (UserManager.Level)Enum.Parse(typeof(UserManager.Level), level);
            user.LastIP = Request.UserHostAddress;
            user.LastLogin = DateTime.Now;

            user.SignIP = Request.UserHostAddress;
            user.Status = ClickModels.UserManager.Status.Active;
            user.Verified = true;
            user.ResetCode = Globals.RandomString(6);
            user.CreatedOn = System.DateTime.Now;

            user.ID = UserManager.AddUserByAdmin(user);

            SendVerificationMail(user);
            ViewBag.Done = true;

            return View();


        }



        private void SendVerificationMail(UserManager.User user)
        {
            Task task = new Task(() =>
            {
                //Send verification email
                string eml = System.IO.File.ReadAllText(Server.MapPath("~/app_data/verifymail.txt"));
                eml = eml.Replace("[username]", user.Name);
                eml = eml.Replace("[appname]", Globals.APPNAME);
                eml = eml.Replace("[vericode]", user.ResetCode);
                eml = eml.Replace("[appurl]", Globals.APPURL);
                eml = eml.Replace("[userid]", user.ID.ToString());

                Globals.SendMail(user.Email, "Verify your " + Globals.APPNAME + " membership.", eml);
            });
            task.Start();
        }
        [HttpPost]
        public ActionResult ChangeStatus(int id, string status)
        {
            UserManager.UpdateStatus(id, status);
            return View();

        }

        [HttpPost]
        public ActionResult ChangeLevel(int userID, string level)
        {
            UserManager.UpdateLevel(userID, level);
            return View();

        }
        [HttpPost]
        public ActionResult UpdateAd(string AdName, string Title, string subtitle, int userid)
        {
            AdManager.Ad ad = new AdManager.Ad();
            ad.ID = userid;
            ad.AdName = AdName;
            ad.Title = Title;
            ad.Subtitle = subtitle;
            AdManager.UpdateParticularAd(ad);
            return RedirectToAction("Userads", new { userid = userid });

        }
    }
}

AnswerRe: Verify Email problem with AdminControler.cs Pin
Afzaal Ahmad Zeeshan20-Feb-17 11:09
professionalAfzaal Ahmad Zeeshan20-Feb-17 11:09 
GeneralRe: Verify Email problem with AdminControler.cs Pin
John Nederveen20-Feb-17 12:57
John Nederveen20-Feb-17 12:57 
SuggestionRe: Verify Email problem with AdminControler.cs Pin
Afzaal Ahmad Zeeshan20-Feb-17 22:49
professionalAfzaal Ahmad Zeeshan20-Feb-17 22:49 
GeneralRe: Verify Email problem with AdminControler.cs Pin
John Nederveen21-Feb-17 6:03
John Nederveen21-Feb-17 6:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.