コード例 #1
0
ファイル: Global.asax.cs プロジェクト: pinkrrr/testingmodules
        protected void Application_Error(object sender, EventArgs e)
        {
            Exception     exept  = Server.GetLastError();
            HttpException httpEx = exept as HttpException;

            if (httpEx.GetHttpCode() == 404)
            {
                Server.ClearError();
                Response.Redirect("/Error/NotFound");
            }
            else
            {
                HttpContext con = HttpContext.Current;
                var         url = con.Request.Url.ToString();
                _adding.AddNewError(url, exept.Message);
                Server.ClearError();
                Response.Redirect("/Error/ServerError");
            }
        }
コード例 #2
0
        public ActionResult NewDiscipline(DiscLecotorViewModel model)
        {
            try
            {
                if (model.LectorId != null)
                {
                    _adding.AddNewDiscipline(model.DiscName.TrimEnd().TrimStart(), model.LectorId);
                    TempData["Success"] = "Дисципліна - \"" + model.DiscName.TrimEnd().TrimStart() + "\" була успішно додана!";
                }
            }
            catch (Exception)
            {
                HttpContext con = System.Web.HttpContext.Current;
                var         url = con.Request.Url.ToString();
                _adding.AddNewError(url, "NewDiscipline Name = " + model.DiscName + " LectorId = " + model.LectorId);
                TempData["Fail"] = "Щось пішло не так. Перевірте правильність дій";
            }

            return(RedirectToAction("Disciplines"));
        }