コード例 #1
1
ファイル: HelperExtensions.cs プロジェクト: garysharp/Disco
        public static void HandleException(this ExceptionContext filterContext)
        {
            var ex = filterContext.Exception;
            var contextResponse = filterContext.HttpContext.Response;

            LogException(ex);

            HttpException httpException = new HttpException(null, ex);
            int httpExceptionCode = httpException.GetHttpCode();

            string controllerName = (string)filterContext.RouteData.Values["controller"];
            string actionName = (string)filterContext.RouteData.Values["action"];
            HandleErrorInfo model = new HandleErrorInfo(ex, controllerName ?? "Unknown", actionName ?? "Unknown");
            ViewResult result = new ViewResult
            {
                ViewName = "Error",
                MasterName = "_Layout",
                ViewData = new ViewDataDictionary<HandleErrorInfo>(model),
                TempData = filterContext.Controller.TempData
            };
            
            filterContext.Result = result;
            filterContext.ExceptionHandled = true;
            contextResponse.Clear();
            contextResponse.StatusCode = httpExceptionCode;
            contextResponse.TrySkipIisCustomErrors = true;
        }
コード例 #2
1
ファイル: ErrorController.cs プロジェクト: cbacon91/VideoQuiz
 // GET: Error
 public ActionResult Index()
 {
     //If a 404 is thrown, the system redirects here but without a HandleErrorInfo object, so we make our own.
     HttpException err = new HttpException(404, string.Format("404 - Unrecognized Url - ({0})", Request.Params["aspxerrorpath"]));
     HandleErrorInfo model = new HandleErrorInfo(err, "Error", "Index");
     return View("Error", model);
 }
コード例 #3
0
ファイル: VLog.LogException.cs プロジェクト: MGramolini/vodca
        public static void LogException(HttpException exception)
        {
            if (exception != null)
            {
                Debug.Print(exception.ToString());
                Logger.Error(exception.ToString());

                try
                {
                    var error = new VLogServerSideError(exception);

                    VLogErrorCode weberrorcode = VLog.GetWebErrorCodeOrDefault(error.ErrorCode, VLogErrorTypes.ServerSideIIS);
                    if (weberrorcode != null && !weberrorcode.ExcludeFromLogging)
                    {
                        if (VLog.OnCommitExceptionToServerRepository != null)
                        {
                            VLog.OnCommitExceptionToServerRepository(error);
                        }
                    }
                }
                catch (Exception ex)
                {
                    // IMPORTANT! We swallow any exception raised during the
                    // logging and send them out to the trace . The idea
                    // here is that logging of exceptions by itself should not
                    // be  critical to the overall operation of the application.
                    // The bad thing is that we catch ANY kind of exception,
                    // even system ones and potentially let them slip by.
                    Logger.Error(ex.ToString());
                    Debug.Print(ex.Message);
                }
            }
        }
コード例 #4
0
ファイル: Global.asax.cs プロジェクト: nhtera/CrowdCMS
        private void ShowCustomErrorPage(Exception exception)
        {
            HttpException httpException = exception as HttpException;
            if (httpException == null)
                httpException = new HttpException(500, "Internal Server Error", exception);

            Response.Clear();
            RouteData routeData = new RouteData();
            routeData.Values.Add("controller", "Error");

            switch (httpException.GetHttpCode())
            {

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

                default:
                    routeData.Values.Add("action", "Http404");
                    break;
            }

            Server.ClearError();

            var contentService = (IWebContent)DependencyResolver.Current.GetService(typeof(IWebContent));
            var domainService = (IDomain)DependencyResolver.Current.GetService(typeof(IDomain));
            var userService = (IUser)DependencyResolver.Current.GetService(typeof(IUser));
            var ecommerceService = (IECommerce)DependencyResolver.Current.GetService(typeof(IECommerce));
            //var stripeService = (IStripe) DependencyResolver.Current.GetService(typeof (IStripe));

            IController controller = new ErrorController(domainService, contentService, ecommerceService, userService);
            controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
        }
コード例 #5
0
 public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
 {
     if (WebApiEnabledAttribute.IsDefined(controllerContext.Controller))
     {
         if (!controllerContext.RouteData.Values.ContainsKey(bindingContext.ModelName) && controllerContext.HttpContext.Request.HasBody())
         {
             ContentType requestFormat = controllerContext.RequestContext.GetRequestFormat();
             object model;
             if (TryBindModel(controllerContext, bindingContext, requestFormat, out model))
             {
                 bindingContext.ModelMetadata.Model = model;
                 MyDefaultModelBinder dmb = new MyDefaultModelBinder();
                 dmb.CallOnModelUpdated(controllerContext, bindingContext);
                 if (!MyDefaultModelBinder.IsModelValid(bindingContext))
                 {
                     List<ModelError> details = new List<ModelError>();
                     foreach (ModelState ms in bindingContext.ModelState.Values)
                     {
                         foreach (ModelError me in ms.Errors)
                         {
                             details.Add(me);
                         }
                     }
                     HttpException failure = new HttpException((int)HttpStatusCode.ExpectationFailed, "Invalid Model");
                     failure.Data["details"] = details;
                     throw failure;
                 }
                 return model;
             }
             throw new HttpException((int)HttpStatusCode.UnsupportedMediaType, String.Format(CultureInfo.CurrentCulture, MvcResources.Resources_UnsupportedMediaType, (requestFormat == null ? String.Empty : requestFormat.MediaType)));
         }
     }
     return this._inner.BindModel(controllerContext, bindingContext);
 }
コード例 #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // Log the exception and notify system operators
     ex = new HttpException("defaultRedirect");
     ExceptionUtility.LogException(ex, "Caught in DefaultRedirectErrorPage");
     ExceptionUtility.NotifySystemOps(ex, "Caught in DefaultRedirectErrorPage");
 }
コード例 #7
0
        void Application_Error(object sender, EventArgs e)
        {
            Exception exception = Server.GetLastError();
            if (exception == null)
            {
                exception = new HttpException(500, "Internal Server Error", exception);
            }

            if (exception is HttpException)
            {
                HttpException httpException = exception as HttpException;
                Server.ClearError();
                Response.Clear();

                switch (httpException.GetHttpCode())
                {
                    case 404:
                        Response.Redirect("~/Error/PageNotFound");
                        break;
                    case 500:
                        Response.Redirect("~/Error/InternalServerError");
                        break;
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Handles the Error event of the Application control.
        /// </summary>
        /// <param name="httpapplication">The http application.</param>
        /// <param name="httpexception">The http exception.</param>
        private static void ApplicationOnErrorFilter(HttpApplication httpapplication, HttpException httpexception)
        {
            // Modify if need
            try
            {
                if (httpexception != null)
                {
                    switch ((HttpStatusCode)httpexception.GetHttpCode())
                    {
                        case HttpStatusCode.InternalServerError:
                            // Error caused by Search engine caching of ASP.NET assembly WebResource.axd file(s)
                            // 'WebResource.axd' Or 'ScriptResource.axd'
                            string url = httpapplication.Context.Request.Url.AbsolutePath;
                            if (url.EndsWith(".axd", StringComparison.OrdinalIgnoreCase))
                            {
                                httpapplication.Context.Server.ClearError();
                            }

                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                // CRITICAL: Error Log must not throw unhandled errors
                Logger.InfoException(ex.Message, ex);
            }
        }
コード例 #9
0
ファイル: ErrorController.cs プロジェクト: Mavtak/roomie
 public ActionResult Http403(HttpException exception)
 {
     return RedirectToAction(
         actionName: "SignIn",
         controllerName: "User"
         );
 }
コード例 #10
0
        public ActionResult Checkout()
        {
            if (new CartBusiness { UserKey = Session.GetUserKey() }.GetCurrentCartCount() <= 0)
            {
                var ex = new HttpException(400, "");
                ex.Data["ErrType"] = Globals.ERRTYPES.CART_CARTEMPTY;
                throw ex;
            }
            var orderBusiness = new OrderBusiness();
            var currentOrder = orderBusiness.GetIncompleteOrder(Session.GetUserKey());
            if (currentOrder == null)
            {
                var ex = new HttpException(404, "");
                ex.Data["ErrType"] = Globals.ERRTYPES.ORDER_NOTFOUND;
                throw ex;
            }

            decimal ItemsTotal;
            decimal ShippingPrice;
            decimal OrderTotal;
            orderBusiness.CalculateOrderSummary(out ItemsTotal, out ShippingPrice, out OrderTotal, currentOrder);

            return View(new CheckoutViewModel
            {
                Order = currentOrder,
                ItemsTotal = ItemsTotal,
                ShippingPrice = ShippingPrice,
                OrderTotal = OrderTotal
            });
        }
コード例 #11
0
        public ActionResult Checkout(Payment Payment)
        {
            if (new CartBusiness { UserKey = Session.GetUserKey() }.GetCurrentCartCount() <= 0)
            {
                var ex = new HttpException(400, "");
                ex.Data["ErrType"] = Globals.ERRTYPES.CART_CARTEMPTY;
                throw ex;
            }
            var orderBusiness = new OrderBusiness();
            var currentOrder = orderBusiness.GetIncompleteOrder(Session.GetUserKey());
            if (currentOrder == null)
            {
                var ex = new HttpException(404, "");
                ex.Data["ErrType"] = Globals.ERRTYPES.ORDER_NOTFOUND;
                throw ex;
            }

            decimal ItemsTotal;
            decimal ShippingPrice;
            decimal OrderTotal;
            orderBusiness.CalculateOrderSummary(out ItemsTotal, out ShippingPrice, out OrderTotal, currentOrder);
            if (OrderTotal != Payment.AmountPaid)
            {
                var ex = new HttpException(400, "");
                ex.Data["ErrType"] = Globals.ERRTYPES.CHECKOUT_PAYMENTERROR;
                throw ex;
            }

            orderBusiness.Checkout(Payment, currentOrder);

            // order completed, SEND E-MAIL

            return RedirectToAction("CheckoutComplete", currentOrder);
        }
コード例 #12
0
ファイル: Global.asax.cs プロジェクト: sdf333/MVCDEMO
        protected void Application_Error()
        {
            if (HttpContext.Current == null)
            {
                // errors in Application_Start will end up here

                return;
            }

            if (HttpContext.Current.IsCustomErrorEnabled)
            {
                return;
            }
            var exception = Server.GetLastError();

            var httpException = new HttpException(null, exception);
            if (httpException.GetHttpCode() == 404 && WebHelper.IsStaticResource(this.Request))
            {
                return;
            }

            //TODO: 记录Log(忽略404,403)
            var routeData = new RouteData();
            routeData.Values.Add("controller", "Error");
            routeData.Values.Add("action", "Index");
            routeData.Values.Add("httpException", httpException);

            Server.ClearError();

            // Call target Controller and pass the routeData.
            //Ref nop&nblog
            IController errorController = SDFEngine.Container.Resolve<ErrorController>();

            errorController.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
        }
コード例 #13
0
ファイル: ErrorPage.aspx.cs プロジェクト: stojaget/Contacts
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create safe error messages.
            string generalErrorMsg = "A problem has occurred on this web site. Please try again. " +
                "If this error continues, please contact support.";
            string httpErrorMsg = "An HTTP error occurred. Page Not found. Please try again.";
            string unhandledErrorMsg = "The error was unhandled by application code.";

            // Display safe error message.
            FriendlyErrorMsg.Text = generalErrorMsg;

            // Determine where error was handled.
            string errorHandler = Request.QueryString["handler"];
            if (errorHandler == null)
            {
                errorHandler = "Error Page";
            }

            // Get the last error from the server.
            Exception ex = Server.GetLastError();

            // Get the error number passed as a querystring value.
            string errorMsg = Request.QueryString["msg"];
            if (errorMsg == "404")
            {
                ex = new HttpException(404, httpErrorMsg, ex);
                FriendlyErrorMsg.Text = ex.Message;
            }

            // If the exception no longer exists, create a generic exception.
            if (ex == null)
            {
                ex = new Exception(unhandledErrorMsg);
            }
        }
コード例 #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // Log the exception and notify system operators
     ex = new HttpException("HTTP 404");
     ExceptionUtility.LogException(ex, "Caught in Http404ErrorPage");
     ExceptionUtility.NotifySystemOps(ex);
 }
コード例 #15
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="VLogServerSideError"/> class.
        /// from a given <see cref="HttpException"/> instance and 
        /// <see cref="HttpContext"/> instance representing the HTTP 
        /// context during the exception.
        /// </summary>
        /// <param name="httpexception">The occurred server side exception</param>
        public VLogServerSideError(HttpException httpexception)
            : this()
        {
            HttpContext context = HttpContext.Current;
            if (httpexception != null && context != null)
            {
                this.ErrorMessage = httpexception.GetErrorMessage();
                this.ErrorDetails = httpexception.GetErrorErrorDetails();

                // Sets an object of a uniform resource identifier properties
                this.SetAdditionalHttpContextInfo(context);
                this.SetAdditionalExceptionInfo(httpexception);

                // If this is an HTTP exception, then get the status code
                // and detailed HTML message provided by the host.
                this.ErrorCode = httpexception.GetHttpCode();

                VLogErrorCode errorcoderule;

                if (VLog.WebErrorCodes.TryGetValue(this.ErrorCode, out errorcoderule) && !errorcoderule.ExcludeFromLogging)
                {
                    this.AddHttpExceptionData(errorcoderule, context, httpexception, errorcoderule);
                }
            }
        }
コード例 #16
0
ファイル: Global.asax.cs プロジェクト: seba-i/Template
        protected void Application_Error(object sender, EventArgs e)
        {
            var exception = Server.GetLastError();

            WebServiceException webEx = exception as WebServiceException;
            if (webEx != null) {
                log.ErrorFormat("Api Error => {0}", webEx.ErrorMessage);
            }

            var httpException = new HttpException(null, exception);
            log.Error("Application Error", exception);

            if (!HttpContext.Current.IsCustomErrorEnabled)
                return;

            var routeData = new RouteData();
            routeData.Values.Add("controller", "Error");
            routeData.Values.Add("action", "Index");
            routeData.Values.Add("httpException", httpException);

            Server.ClearError();

            var errorController = ControllerBuilder.Current.GetControllerFactory().CreateController(
                new RequestContext(new HttpContextWrapper(Context), routeData), "Error");

            errorController.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
        }
コード例 #17
0
        public WebErrorHandler HandleException()
        {
            var exception = HttpContext.Current.Server.GetLastError();
            
            if (null != exception)
            {
                // by default 500
                var statusCode = (int)HttpStatusCode.InternalServerError;
                if (exception is HttpException)
                {
                    statusCode = new HttpException(null, exception).GetHttpCode();
                }
                else if (exception is UnauthorizedAccessException)
                {
                    // to prevent login prompt in IIS
                    // which will appear when returning 401.
                    statusCode = (int)HttpStatusCode.Forbidden;
                }

                if ((LogHttpNotFound && statusCode == 404) || statusCode != 404)
                {
                    if (null != _loggerFunc)
                    {
                        LoggerFunc(string.Format("ASP.NET Error Captured, Request URL: {0}, Exception:",
                            HttpContext.Current.Request.Url), exception);
                    }
                }

                ExceptionInfo = exception.Message;
                _statusCode = statusCode;
            }
            return this;
        }
コード例 #18
0
        public void GetErrorInfoFromException_GivenHttpExceptionWithNoInnerExceptionReturnsExceptionMessageAsTitle()
        {
            var ex = new HttpException("Test exception message");
            var errorInfo = service.GetErrorInfoFromException(ex, "testpage.htm", "Tester", "TestApp");

            Assert.IsNotNull(errorInfo);
            Assert.IsTrue(errorInfo.ErrorTitle == "Test exception message");
        }
コード例 #19
0
ファイル: RoadkillApplication.cs プロジェクト: 35e8/roadkill
		protected void Application_Error()
		{
			// Log ASP.NET errors (404, 500)
			HttpException exception = new HttpException(null, HttpContext.Current.Server.GetLastError());
			Log.Error("An ASP.NET based error occurred - ({0}) - {1}", 
						exception.GetHttpCode(),
						exception.ToString());
		}
コード例 #20
0
        public void Increment_With404HttpException_DoesntAddReadingData()
        {
            var sensor = new ExceptionSensor();

            var exception = new HttpException(404, "Page not found");
            sensor.AddError(exception);

            Assert.That(ReadingPublisher.Readings.Count, Is.EqualTo(0));
        }
コード例 #21
0
        public override System.Web.Mvc.ActionResult Index(string catchAll, System.Web.HttpException exception)
        {
            var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Index);

            ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "catchAll", catchAll);
            ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "exception", exception);
            IndexOverride(callInfo, catchAll, exception);
            return(callInfo);
        }
コード例 #22
0
 public void HandleUnknownStatusCodeFromHttpException()
 {
   HttpException exception = new HttpException(1, "?");
   _builder.SetExceptionDetails(exception);
   RaygunMessage message = _builder.Build();
   Assert.IsNotNull(message.Details.Response);
   Assert.AreEqual(1, message.Details.Response.StatusCode);
   Assert.IsNull(message.Details.Response.StatusDescription);
 }
コード例 #23
0
 public void GetStatusCodeFromHttpException()
 {
   HttpException exception = new HttpException(404, "the file is gone");
   _builder.SetExceptionDetails(exception);
   RaygunMessage message = _builder.Build();
   Assert.IsNotNull(message.Details.Response);
   Assert.AreEqual(404, message.Details.Response.StatusCode);
   Assert.AreEqual("NotFound", message.Details.Response.StatusDescription);
 }
コード例 #24
0
ファイル: Global.asax.cs プロジェクト: gabykotliar/ScrumBoard
        private RouteData GetErrorRouteData(HttpException httpException, CustomErrorsSection config)
        {
            var statusCode = httpException.GetHttpCode().ToString(CultureInfo.InvariantCulture);

            var routeData = RouteInfo.GetRouteDataByUrl(config.Errors[statusCode] != null
                                             ? config.Errors[statusCode].Redirect
                                             : config.DefaultRedirect);

            return routeData;
        }
コード例 #25
0
 public void LogHttpException(HttpRequestBase httpRequest, HttpException httpException)
 {
     if (httpException == null) return;
     if (httpRequest == null)
     {
         LogException(httpException);
         return;
     }
     _log.ErrorFormat(HttpErrorFormat, httpException.Message, httpRequest.UserAgent, httpRequest.Url, httpException.StackTrace);
 }
コード例 #26
0
        public ExceptionContext MockThrowing404Exception()
        {
            HttpException exception = new HttpException(NotFound, "error");

            ExceptionContext context = new ExceptionContext(ControllerContext, exception);

            OnException(context);

            return context;
        }
コード例 #27
0
        public void MediumTrustThrowsSecurityExceptionWhenCopyingBetweenTypesFromDifferentModules()
        {
            Exception e1 = new Exception("my name is e1");
            HttpException e2 = new HttpException("my name is e2");
            // I know, I am a bit paranoid about that basic assumption
            Assert.AreNotEqual( e1.GetType().Assembly, e2.GetType().Assembly );

            SecurityTemplate.MediumTrustInvoke(new ThreadStart(new CopyCommand(e2, e1).Execute));
            Assert.AreEqual(e1.Message, e2.Message);
        }
コード例 #28
0
        public HttpResponseException General(HttpException ex)
        {
            Debug.WriteLine(GetType().FullName + "." + MethodBase.GetCurrentMethod().Name);

            string strHtmlError = ex.GetBaseException().ToString();
            @ViewBag.strError = strHtmlError;

            //return View("Error");
            return new HttpResponseException(HttpStatusCode.InternalServerError);
        }
コード例 #29
0
ファイル: ErrorController.cs プロジェクト: Mavtak/roomie
        public ActionResult Http404(HttpException exception)
        {
            var path = "/angular/#" + Request.Path;

            if (Request.QueryString.Count > 0)
            {
                path += "?" + Request.QueryString;
            }

            return Redirect(path);
        }
コード例 #30
0
        public void http_exception_404_should_not_send()
        {
            var client = new FakeAirbrakeClient();
            var exception = new HttpException(404, "not found");

            exception.SendToAirbrake(client: client);

            Assert.AreEqual(0, client.SentExceptions.Count);
            Assert.AreEqual(0, client.SentNotices.Count);

        }
コード例 #31
0
        public void ProcessException(Exception ex, HttpContext ctx)
        {
            if(ex == null)
                return;

            Type exType = ex.GetType();

            if (typeof(RequestedResourceNotFoundException).IsAssignableFrom(exType))
                ex = new HttpException(404, ex.Message, ex);

            ErrorLog.GetDefault(ctx).Log(new Error(ex, ctx));
        }
コード例 #32
0
 private void Application_OnError(object sender, System.EventArgs e)
 {
     System.Web.HttpApplication httpApplication = (System.Web.HttpApplication)sender;
     System.Web.HttpContext     context         = httpApplication.Context;
     System.Exception           ex = context.Server.GetLastError();
     if (ex is System.Web.HttpException)
     {
         System.Web.HttpException ex2 = ex as System.Web.HttpException;
         if (ex2.GetHttpCode() == 404)
         {
             string arg_41_0 = httpApplication.Request.PhysicalPath;
             TextLogger.Write(string.Format("文件不存在:{0}", httpApplication.Request.Url.AbsoluteUri));
             return;
         }
     }
     if (ex.InnerException != null)
     {
         ex = ex.InnerException;
     }
     System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder().AppendFormat("访问路径:{0}", GameRequest.GetRawUrl()).AppendLine().AppendFormat("{0} thrown {1}", ex.Source, ex.GetType().ToString()).AppendLine().Append(ex.Message).Append(ex.StackTrace);
     TextLogger.Write(stringBuilder.ToString());
 }
コード例 #33
0
 partial void IndexOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string catchAll, System.Web.HttpException exception);
コード例 #34
0
        public static void SendErrorResponse(HttpResponseBase response, System.Web.HttpException he, string moduleVersion)
        {
            int    httpStatusCode = he.GetHttpCode();
            string msgType        = StatusCodeMessage(httpStatusCode);

            string errorDoc = null;

            try
            {
                errorDoc = Utilities.GetXmlStringFromFile(Settings.Get(("ErrorTemplate")));
            }
            catch (Exception ex)
            {
                // use default template if we can't find the requested one
                if (string.IsNullOrEmpty(errorDoc))
                {
                    errorDoc =
                        "<?xml version=\"1.0\" encoding=\"utf-8\"?><!DOCTYPE html PUBLIC \"-/W3C/DTD XHTML 1.0 Transitional/EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns = \"http:/www.w3.org/1999/xhtml\"><head><title>Application Error - {0} {1}</title></head><body style=\"font-family:Arial; font-size:10pt; color:#330000\"><h1>{0} {1}</h1><div class=\"error_message\">{2}</div><b><span class=\"error_location\">{4}.{3}</span></b><!--\n{5}\n--><br/><br/>In addition, the error page could not be loaded, so this default page was used instead.\n<!--THE FOLLOWING EXCEPTION OCCURRED WHILE LOADING THE ERROR TEMPLATE:\n" +
                        ex.Message + "\n--><hr/><i>RestNet Application {6}</i></body></html>";
                }
            }

            var url = (HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.Url != null) ? string.Format(" ({0})", HttpContext.Current.Request.Headers["X-REWRITE-URL"] ?? HttpContext.Current.Request.Url.PathAndQuery) : string.Empty;

            System.Reflection.MethodBase targetSite = he.GetBaseException().TargetSite;
            string msg = string.Format(errorDoc,
                                       httpStatusCode,
                                       msgType,
                                       he.Message + url,
                                       targetSite == null ? string.Empty : targetSite.Name,
                                       targetSite == null ? string.Empty : targetSite.ReflectedType.FullName,
                                       System.Web.HttpUtility.HtmlEncode(he.GetBaseException().StackTrace),
                                       moduleVersion);

            // Set logging level differently for client vs. server errors.
            // 100, 200, 300 series should never really appear, but just in case I've included them here
            // also, don't bother including full exceptions for < 500, as they're likely to just duplicate the message
            switch ((int)(httpStatusCode / 100))
            {
            case 0:
            case 1:
            case 2:
                Logging.Debug(he.Message + url);
                break;

            case 3:
                Logging.InfoFormat("{0} - {1}", httpStatusCode, he.Message + url);
                break;

            case 4:
                if (httpStatusCode == 401)
                {
                    // 401 challenge isn't really worthy of a warning
                    Logging.DebugFormat("{0} - {1}", httpStatusCode, he.Message + url);
                }
                else
                {
                    Logging.WarnFormat("{0} - {1}", httpStatusCode, he.Message + url);
                }
                break;

            default:
                Logging.Error(string.Format("{0} - {1}", httpStatusCode, he.Message + url), he);
                break;
            }
            ReturnError(response, httpStatusCode, msg);
        }
コード例 #35
0
 public static void SendErrorResponse(HttpResponse response, System.Web.HttpException he, string moduleVersion)
 {
     SendErrorResponse(new HttpResponseWrapper(response), he, moduleVersion);
 }
コード例 #36
0
 public static void SendErrorResponse(HttpResponseBase response, System.Web.HttpException he)
 {
     SendErrorResponse(response, he, string.Empty);
 }
コード例 #37
0
 public static void SendErrorResponse(HttpResponse response, System.Web.HttpException he)
 {
     SendErrorResponse(new HttpResponseWrapper(response), he);
 }