示例#1
0
        protected void Application_Error()
        {
            var    err     = Server.GetLastError() as Exception;
            string errorId = string.Empty;
            var    dr      = new DbResult();

            if (err != null)
            {
                var           page          = HttpContext.Current.Request.Url.ToString();
                var           urlReferrer   = HttpContext.Current.Request.UrlReferrer;
                HttpException httpException = err as HttpException;
                string        errorCode     = string.Empty;
                string        errDetails    = string.Empty;
                if (httpException != null) // keep record of HttpException
                {
                    int httpCode = httpException.GetHttpCode();

                    errorCode  = Convert.ToString(httpCode);
                    errorId    = Convert.ToString(errorCode);
                    errDetails = GlobalHelper.FilterString(httpException.GetHtmlErrorMessage());
                }

                CommonLibraryService commonLibraryService = new CommonLibraryService();

                if (Session["userName"] != null && (errorCode != "500" || errorCode != "501" || errorCode != "502" || errorCode != "503"))
                {
                    dr = commonLibraryService.LogError(err, page, GetAbsoluteUri(urlReferrer));
                }


                Server.ClearError();

                if (!string.IsNullOrEmpty(dr.Id) && dr.Id != "0")
                {
                    errorId = dr.Id.ToString();
                }
                Application["code"] = errorId + '|' + errorCode.ToString();
                this.Response.RedirectToRoute("Default", new { controller = "Error", action = "Error" });
            }
        }
示例#2
0
 public CommonLibraryController(CommonLibraryService service)
 {
     _service = service;
 }