protected override void OnException(ExceptionContext filterContext) { if (Util.ServerIsDev || Util.IsBewebOffice) { // fall through to Global asax error handler - and display error onscreen - we want to see full debug info on screen filterContext.ExceptionHandled = false; } else if (filterContext.Exception is BadUrlException) { // todo - make this return a Shared View instead of a Redirect to Action // filterContext.Result = View("BadUrl", new{message=filterContext.Exception.Message}); filterContext.Result = Redirect("~/Admin/NotFound?message=" + filterContext.Exception.Message); filterContext.ExceptionHandled = true; } else if (filterContext.Exception is AdminErrorException) { SendEMail.SimpleSendEmail(SendEMail.EmailToAddress, Util.GetSiteName() + " Website Problem Notification", "Please address the following issue with the website:\n" + filterContext.Exception.Message); filterContext.Result = Redirect("~/Admin/ShowError?message=" + filterContext.Exception.Message.UrlEncode()); filterContext.ExceptionHandled = true; // fall through to Global asax error handler - and show standard error page //} else { //if (filterContext.Exception is ProgrammingErrorException) { // Beweb.Error.SendExceptionEmail(); // filterContext.Result = Redirect("~/Admin/ShowError?message=" + "A programming error occurred. Please contact the developers.".UrlEncode()); // filterContext.ExceptionHandled = true; //} else { // // fall through to Global asax error handler - and show standard error page - maybe don't need this? // filterContext.ExceptionHandled = false; } }
/// <summary> /// When a new person subscribes, you need to add a Person record for them (using Models.Person) and complete all the fields you have data for, then pass it to this method. /// This method sends an email to the person asking them to click a link. /// The final part of double opt in is when the link is clicked. The link takes them back to the Subscribe page with a URL parameter of "optin=[encryptedid]", and you need to call VerificationLinkClicked(Request["optin"]). /// </summary> /// <param name="person">A Models.Person object with email address and any other fields completed.</param> /// <param name="subscribePageFileName">File name of subscribe or optin page that calls VerificationLinkClicked (may include path from site root, may start with ~)</param> public static void SendVerificationEmail(ActiveRecord person, string subscribePageFileName) { // check person record is OK AssertFieldsExist(person); string email = person["Email"].ToString(); // validate if (email.IsBlank()) { throw new Exception("NewsletterDoubleOptIn: Email address was null or empty."); } if (!email.IsEmail()) { throw new Exception("NewsletterDoubleOptIn: Email address was not valid [" + email + "]."); } // send double opt in email Models.TextBlock emailText = Models.TextBlock.LoadBySectionCode("Double_OptIn_Email"); // create if not found if (emailText == null) { emailText = new Models.TextBlock() { SectionCode = "Double_OptIn_Email", IsBodyPlainText = true, IsTitleAvailable = true, BodyTextHtml = string.Format("Please confirm that you wish to subscribe to our email newsletter.{0}{0}Click the link below if you wish to subscribe:", Environment.NewLine), Title = "Email Newsletter - Please Confirm" }; emailText.Save(); } string emailBody = emailText.BodyTextHtml; emailBody += Environment.NewLine + Web.ResolveUrlFull(subscribePageFileName) + "?optin=" + Crypto.EncryptID((int)person["PersonID"].ValueObject).UrlEncode(); SendEMail.SimpleSendEmail(email, emailText.Title, emailBody); person["DoubleOptInEmailSentDate"].ValueObject = DateTime.Now; person.Save(); }
public void Init() { int blogid = Crypto.DecryptID(Web.Request["id"]); var blogSql = new Sql("select * from blog where blogid=", blogid, " and ispublished=1"); var rec = blogSql.GetHashtable(); BlogTitle = rec["Title"] + ""; BlogBody = rec["BodyText"] + ""; BlogDate = rec["DateAdded"] + ""; Sql mainlist = new Sql("select top 25 * from blogcomment where blogid=", blogid, " and ispublished=1 order by dateadded desc"); blogCommentList = mainlist.GetDataTable(); Url = Web.Server.UrlEncode(Web.ResolveUrlFull("~") + "blogdetail.aspx?page=" + Web.Request["page"] + "&id=" + Web.Request["id"]); bool autopublish = false; if (Web.Request["go"] != null) { int id = (Web.Session["CurrentUserID"] + "").ToInt(-1); if (id > 0) { autopublish = true; } var sql = new Sql(@"insert into blogcomment(title,bodytext ,[Company] ,[FirstName] ,[LastName] ,[Email],CommentByPersonID, blogid, dateadded, ispublished) values(" ); sql.Add("", (Web.Request["title"] + "").SqlizeText(), ",", (Web.Request["body"] + "").SqlizeText(), ","); sql.Add("", (Web.Request["company"] + "").SqlizeText(), ",", (Web.Request["firstname"] + "").SqlizeText(), ",", (Web.Request["lastname"] + "").SqlizeText(), ",", (Web.Request["email"] + "").SqlizeText(), ","); sql.Add("", (id + "").SqlizeNumber(), ",", blogid.SqlizeNumber(), ", getdate(),", autopublish.SqlizeBool(), ");select @@identity;"); decimal savedNewID = (sql).FetchDecimalOrZero(); //send email //Response.Write("ok"); string adminurl = Web.ResolveUrlFull("~/admin/") + "BlogCommentAdmin/EditEnc?encID=" + Crypto.EncryptID(savedNewID.ToInt()); //string EmailToAddress = Util.GetSetting("BlogEmailToAddress"); string EmailToAddress = Util.GetSetting("EmailToAddress"); //fromemail = "*****@*****.**"; //EmailToAddress = "*****@*****.**"; string msg = "" + "Site Admin,\n" + "\n" + " A new comment has been posted to your blog."+ "\n" + " Link to admin: "+ adminurl + "" + "\n"; if (!autopublish) { msg += " Note that you will to review the data and publish it if it has appropriate content."+ "\n"; } else { msg += " This was auto-published, as it was created by a logged in user."+ "\n"; } SendEMail.SimpleSendEmail(EmailToAddress, Util.GetSiteName() + " : New Blog Comment", msg); //reload page string url = Web.Request.RawUrl.ToString(); //Response.Redirect(url + (url.Contains("&post") ? "" : "&post=1")); } }