internal static void TransferToErrorPage(string cause, bool showCallStack) { HttpContext httpContext = HttpContext.Current; if (httpContext.IsWebServiceRequest()) { ErrorHandlingModule.SendJsonError(httpContext, httpContext.GetError(), cause); return; } if (httpContext.IsUploadRequest()) { ErrorHandlingModule.SendJsonErrorForUpload(httpContext, httpContext.GetError()); return; } EcpPerfCounters.RedirectToError.Increment(); if (!showCallStack) { httpContext.ClearError(); } httpContext.Response.Clear(); string text = string.Format("~/error.aspx?cause={0}", cause); string text2 = httpContext.Request.QueryString["isNarrow"]; if (text2 != null) { text = EcpUrl.AppendQueryParameter(text, "isNarrow", text2); } httpContext.Server.Transfer(text); }
private static void Application_EndRequest(object sender, EventArgs e) { HttpContext context = HttpContext.Current; if (context.IsUploadRequest()) { HttpResponse response = HttpContext.Current.Response; if (response.StatusCode == 404 && response.SubStatusCode == 13) { HttpException e2 = new HttpException(Strings.FileExceedsIISLimit); ErrorHandlingModule.SendJsonErrorForUpload(context, e2); } } }
private static void Application_Error(object sender, EventArgs e) { HttpContext httpContext = HttpContext.Current; Exception ex = httpContext.GetError(); ExTraceGlobals.EventLogTracer.TraceError <EcpTraceFormatter <Exception> >(0, 0L, "Application Error: {0}", ex.GetTraceFormatter()); DDIHelper.Trace("Application Error: {0}", new object[] { ex.GetTraceFormatter() }); EcpPerfCounters.AspNetErrors.Increment(); EcpEventLogConstants.Tuple_RequestFailed.LogPeriodicFailure(EcpEventLogExtensions.GetUserNameToLog(), httpContext.GetRequestUrlForLog(), ex, EcpEventLogExtensions.GetFlightInfoForLog()); RbacPrincipal current = RbacPrincipal.GetCurrent(false); string tenantName = string.Empty; if (current != null) { OrganizationId organizationId = current.RbacConfiguration.OrganizationId; if (organizationId != null && organizationId.OrganizationalUnit != null) { tenantName = organizationId.OrganizationalUnit.Name; } } ActivityContextLogger.Instance.LogEvent(new PeriodicFailureEvent(ActivityContext.ActivityId.FormatForLog(), tenantName, httpContext.GetRequestUrlForLog(), ex, EcpEventLogExtensions.GetFlightInfoForLog())); ActivityContextManager.CleanupActivityContext(httpContext); if (ex is DelegatedSecurityTokenExpiredException) { ErrorHandlingModule.HandleDelegatedSecurityTokenExpire(httpContext); return; } if (httpContext.IsWebServiceRequest()) { string errorCause = DiagnosticsBehavior.GetErrorCause(ex); ErrorHandlingUtil.SendReportForCriticalException(httpContext, ex); ErrorHandlingModule.SendJsonError(httpContext, ex, errorCause); return; } if (httpContext.IsUploadRequest()) { ErrorHandlingUtil.SendReportForCriticalException(httpContext, ex); ErrorHandlingModule.SendJsonErrorForUpload(httpContext, ex); return; } if (ex is HttpException && ex.InnerException != null) { ex = ex.InnerException; } httpContext.Request.ServerVariables["X-ECP-ERROR"] = ex.GetType().FullName; string text = null; string text2 = null; if (ex is OverBudgetException) { text = "overbudget"; } else if (ex is IdentityNotMappedException || ex is TransientException) { text = "transientserviceerror"; } else if (ex is ObjectNotFoundException) { if (ex.InnerException is NonUniqueRecipientException) { text = "nonuniquerecipient"; } else { text = "nonmailbox"; } } else if (ex is ServerNotInSiteException || ex is LowVersionUserDeniedException) { text = "lowversion"; } else if (ex is CmdletAccessDeniedException || ex is DelegatedAccessDeniedException) { text = "noroles"; } else if (ex is UrlNotFoundOrNoAccessException) { text = "urlnotfoundornoaccess"; } else if (ex is BadRequestException) { text = "badrequest"; } else if (ex is BadQueryParameterException) { text = "badqueryparameter"; } else if (ex is ProxyFailureException) { text = "transientserviceerror"; } else if (ex is ProxyCantFindCasServerException) { text = "proxy"; } else if (ex is CasServerNotSupportEsoException) { text = "noeso"; } else if (ex is RegionalSettingsNotConfiguredException) { text = "regionalsettingsnotconfigured"; } else if (ex is SecurityException || (ErrorHandlingUtil.KnownReflectedExceptions.Value.ContainsKey("Microsoft.Exchange.Hygiene.Security.Authorization.NoValidRolesAssociatedToUserException, Microsoft.Exchange.Hygiene.Security.Authorization") && ex.GetType() == ErrorHandlingUtil.KnownReflectedExceptions.Value["Microsoft.Exchange.Hygiene.Security.Authorization.NoValidRolesAssociatedToUserException, Microsoft.Exchange.Hygiene.Security.Authorization"])) { text = "noroles"; } else if (ex is ExchangeConfigurationException) { text = "anonymousauthenticationdisabled"; } else if (ex is CannotAccessOptionsWithBEParamOrCookieException) { text = "cannotaccessoptionswithbeparamorcookie"; } else if (ex.IsMaxRequestLengthExceededException()) { EcpPerfCounters.RedirectToError.Increment(); text2 = httpContext.Request.AppRelativeCurrentExecutionFilePath; } else { ErrorHandlingUtil.SendReportForCriticalException(httpContext, ex); if (!ErrorHandlingUtil.ShowIisNativeErrorPage && !ex.IsInterestingHttpException()) { text = "unexpected"; } } if (text2 != null) { httpContext.Server.Transfer(text2, true); return; } if (text != null) { ErrorHandlingModule.TransferToErrorPage(text, ErrorHandlingUtil.CanShowDebugInfo(ex)); } }