protected override void WriteInitializationLog() { EcpEventLogConstants.Tuple_StandardSessionInitialize.LogEvent(new object[] { base.NameForEventLog, EcpEventLogExtensions.GetFlightInfoForLog() }); }
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)); } }
void IErrorHandler.ProvideFault(Exception error, MessageVersion version, ref Message fault) { string value = DiagnosticsBehavior.GetErrorCause(error) ?? error.GetType().FullName; EcpPerfCounters.WebServiceErrors.Increment(); EcpEventLogConstants.Tuple_WebServiceFailed.LogPeriodicFailure(EcpEventLogExtensions.GetUserNameToLog(), HttpContext.Current.GetRequestUrlForLog(), error, EcpEventLogExtensions.GetFlightInfoForLog()); ExTraceGlobals.EventLogTracer.TraceError <string, EcpTraceFormatter <Exception> >(0, 0L, "{0}'s webservice request failed with exception: {1}", EcpEventLogExtensions.GetUserNameToLog(), error.GetTraceFormatter()); HttpContext.Current.Response.AddHeader("X-ECP-ERROR", value); DDIHelper.Trace("Webservice request failed with exception: {0}", new object[] { error.GetTraceFormatter() }); if (fault != null && version == MessageVersion.None) { MessageProperties properties = fault.Properties; fault = Message.CreateMessage(version, string.Empty, new JsonFaultDetail(error), new DataContractJsonSerializer(typeof(JsonFaultDetail))); fault.Properties.CopyProperties(properties); } }
public static void InitializeActivityContext(HttpContext httpContext, ActivityContextLoggerId eventId = ActivityContextLoggerId.Request) { try { if (httpContext != null && !ActivityContext.IsStarted) { ActivityScope activityScope = ActivityContext.DeserializeFrom(httpContext.Request, null); activityScope.SetProperty(ExtensibleLoggerMetadata.EventId, eventId.ToString()); if (activityScope.DisposeTracker is DisposeTrackerObject <ActivityScope> ) { activityScope.DisposeTracker.AddExtraData(httpContext.GetRequestUrl().ToString()); } httpContext.Items[ActivityContextManager.ECPActivityScopePropertyName] = activityScope; } } catch (Exception exception) { EcpEventLogConstants.Tuple_ActivityContextError.LogPeriodicFailure(EcpEventLogExtensions.GetUserNameToLog(), httpContext.GetRequestUrlForLog(), exception, EcpEventLogExtensions.GetFlightInfoForLog()); } }
public static void CleanupActivityContext(HttpContext httpContext) { try { if (httpContext != null) { ActivityScope activityScope = (ActivityScope)httpContext.Items[ActivityContextManager.ECPActivityScopePropertyName]; if (activityScope != null) { httpContext.Items.Remove(ActivityContextManager.ECPActivityScopePropertyName); if (!activityScope.IsDisposed) { activityScope.End(); } } } } catch (Exception exception) { EcpEventLogConstants.Tuple_ActivityContextError.LogPeriodicFailure(EcpEventLogExtensions.GetUserNameToLog(), httpContext.GetRequestUrlForLog(), exception, EcpEventLogExtensions.GetFlightInfoForLog()); } }
public override void ProcessRequest(HttpContext context) { if (ToolkitScriptManager.CacheScriptBuckets == null) { base.ProcessRequest(context); } try { if (!ToolkitScriptManager.OutputCombineScriptResourcesFile(context)) { throw new BadRequestException(new Exception("'ToolkitScriptManager' could not generate combined script resources file.")); } } catch (Exception ex) { EcpEventLogConstants.Tuple_ScriptRequestFailed.LogPeriodicFailure(EcpEventLogExtensions.GetUserNameToLog(), context.GetRequestUrlForLog(), ex, EcpEventLogExtensions.GetFlightInfoForLog()); throw new BadRequestException(ex); } }