示例#1
0
        public ActionResult SubmitError(SubmitErrorViewModel model)
        {
            string errorMessage = model.UserText + ":\t" + model.ExceptionText;;
            try
            {
                MailMessage message = new MailMessage();
                message.From = new MailAddress("*****@*****.**");
                message.To.Add(new MailAddress("*****@*****.**"));

                message.Subject = "NTXFC web site error";
                ProfileCommon profile = HttpContext.Profile as ProfileCommon;
                if (profile != null)
                {
                    message.Body = "User " + profile.FirstName + " " + profile.LastName + " (LoginID: " + profile.LoginId.ToString() + ") experienced following error:\t"; 
                }
                message.Body += errorMessage;

                SendEmail(message);
            }
            catch (Exception ex)
            {
                string msg = "Error while sending email with error details:\t" + ex.ToString();
                msg += "Original error was:\t" + errorMessage;
                LogError(errorMessage);
            }


            return RedirectToAction("Index");
        }
示例#2
0
        protected override void OnException(ExceptionContext filterContext)
        {
            LogError(filterContext.Exception.ToString());
            try
            {
                //if (filterContext.HttpContext.IsCustomErrorEnabled)
                //{
                SubmitErrorViewModel viewModel = new SubmitErrorViewModel();
                viewModel.ExceptionText = filterContext.Exception.ToString();
                if (User.IsInRole("Admin"))
                {
                    viewModel.ShowErrorDetails = true;
                }

                filterContext.ExceptionHandled = true;
                this.View("Error", viewModel).ExecuteResult(this.ControllerContext);
                //}
            }
            catch (Exception ex)
            {
                LogError("Exception while trying to handle error: " + ex.ToString());
                throw;
            }
        }