public void ProcessRequest(HttpContext context)
        {
            // 取得唯一键与数据库中的所存储的键相比较.
            string key = context.Request.QueryString["k"];

            if (!string.IsNullOrEmpty(key))
            {
                using (EmailAddressValidationDataContext service =
                           new EmailAddressValidationDataContext())
                {
                    tblEmailValidation EValidation =
                        service.tblEmailValidations.Where(
                            t => t.ValidateKey.Trim() == key).FirstOrDefault();
                    if (EValidation != null)
                    {
                        // 通过验证后更新记录.
                        EValidation.IsValidated = true;
                        service.SubmitChanges();

                        // 我们可以定制返回的值并输出.
                        // 这里只是简单的输出信息.
                        context.Response.Write("恭喜! 你的邮箱地址: " +
                                               EValidation.EmailAddress + "已经验证成功!");
                    }
                    else
                    {
                        context.Response.Write("请先提交你的邮箱地址.");
                    }
                }
            }
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            // Get the unique key which is used to compare with
            // the key stored in the database.
            string key = context.Request.QueryString["k"];

            if (!string.IsNullOrEmpty(key))
            {
                using (EmailAddressValidationDataContext service =
                           new EmailAddressValidationDataContext())
                {
                    tblEmailValidation EValidation =
                        service.tblEmailValidations.Where(
                            t => t.ValidateKey.Trim() == key).FirstOrDefault();
                    if (EValidation != null)
                    {
                        // Update the record and make it as validated.
                        EValidation.IsValidated = true;
                        service.SubmitChanges();

                        // We can custom the output of the return message.
                        // Here is just a simple message.
                        context.Response.Write("Congratulation! Your Email Addess: " +
                                               EValidation.EmailAddress + " has been validated!");
                    }
                    else
                    {
                        context.Response.Write("Please submit your address first.");
                    }
                }
            }
        }