Example #1
0
 public BaseController()
 {
     db = new blogDBEntities();
     //ViewBag.MetaDescription = db.siteSettings.FirstOrDefault().seoDescription;
     //ViewBag.MetaKeywords = db.siteSettings.FirstOrDefault().seoKeywords;
     //ViewBag.MetaTitle = db.siteSettings.FirstOrDefault().seoTitle;
 }
Example #2
0
        public void OnException(ExceptionContext filterContext)
        {
            blogDBEntities db     = new blogDBEntities();
            int?           userId = null;

            if (filterContext.HttpContext.Session["login"] != null)
            {
                userId = (filterContext.HttpContext.Session["login"] as user).id;
            }
            db.Logs.Add(new Logs
            {
                userId         = userId,
                actionName     = filterContext.RouteData.Values["action"].ToString(),
                controllerName = filterContext.RouteData.Values["controller"].ToString(),
                time           = DateTime.Now,
                alteration     = "Error :" + filterContext.Exception.Message
            });
            db.SaveChanges();
            filterContext.ExceptionHandled             = true;
            filterContext.Controller.TempData["error"] = filterContext.Exception;
            filterContext.Result = new RedirectResult("~/Error/Index");
        }