ClearError() public method

public ClearError ( ) : void
return void
示例#1
0
        /// <summary>
        /// 异常事件处理
        /// </summary>
        public void DoError()
        {
            //是否自定义处理error
            if (Common.ConfigValue.IsCustomError == false)
            {
                return;
            }
            Exception exception = Server.GetLastError();

            Response.Clear();
            HttpException httpException = exception as HttpException;
            RouteData     route         = new RouteData();

            route.Values.Add("controller", "HttpError");
            if (Request.Url.Segments.Any(q => q.Equals("httperror", StringComparison.InvariantCultureIgnoreCase)))
            {
                Server.ClearError();
                Response.Write("HttpError出错或对应的模板出错!");
                Response.StatusCode = 500;
                Response.End();
                return;
            }
            if (httpException == null)
            {
                route.Values.Add("action", "Status500");
                route.Values.Add("msg", exception.Message);
                Response.StatusCode = 500;
            }
            else
            {
                if (httpException.GetHttpCode() == 404)
                {
                    route.Values.Add("action", "Status404");
                    Response.StatusCode = 404;
                }
                else if (httpException.GetHttpCode() == 509)
                {
                    route.Values.Add("action", "Status509");
                    Response.StatusCode = 509;
                }
                else
                {
                    route.Values.Add("action", "Status500");
                    Response.StatusCode = 500;
                }
                route.Values.Add("msg", httpException.Message);
            }
            IController errorController = this.IContoller;

            errorController.Execute(new RequestContext(new HttpContextWrapper(Application.Context), route));
            Server.ClearError();
            Response.End();
        }
示例#2
0
        public static void ReturnThroughErrorController(HttpServerUtility server, HttpResponse response, HttpContext context)
        {
            var exception = server.GetLastError();
            response.StatusCode = GetStatusCode(exception);

            if (response.StatusCode == 500) return;

            server.ClearError();
            response.Clear();
            var routeData = new RouteData();
            routeData.Values["controller"] = "Errors";
            routeData.Values["action"] = GetActionForStatusCode(response.StatusCode);
            routeData.Values["exception"] = exception;

            IController errorsController = new ErrorsController();
            var requestContext = new RequestContext(new HttpContextWrapper(context), routeData);
            errorsController.Execute(requestContext);
        }
示例#3
0
        public static void ShowCustomErrorPage(HttpServerUtility server, HttpContext context, HttpResponse response)
        {
            var exception = server.GetLastError();
            Logger.SetLog(exception);

            var routeData = new RouteData();
            routeData.Values.Add("controller", "Error");
            routeData.Values.Add("fromAppErrorEvent", true);

            var httpException = exception as HttpException ?? new HttpException(500, "Internal Server Error", exception);
            int httpCode = httpException.GetHttpCode();
            switch (httpCode)
            {
                case 403:
                    routeData.Values.Add("action", "AccessDenied");
                    break;

                case 404:
                    routeData.Values.Add("action", "NotFound");
                    break;

                case 500:
                    routeData.Values.Add("action", "ServerError");
                    break;

                default:
                    routeData.Values.Add("action", "OtherHttpStatusCode");
                    routeData.Values.Add("httpStatusCode", httpCode);
                    break;
            }

            server.ClearError();

            response.Clear();

            IController controller = new ErrorController();
            controller.Execute(new RequestContext(new HttpContextWrapper(context), routeData));
        }
示例#4
0
 public override void ClearError()
 {
     w.ClearError();
 }
示例#5
0
 /// <summary>
 /// See <see cref="HttpServerUtility"/> for a description.
 /// </summary>
 public void ClearError()
 {
     _httpServerUtility.ClearError();
 }
 public override void ClearError()
 {
     _httpServerUtility.ClearError();
 }