void LogServiceActivationException(ServiceActivationException activationException) { if (TD2.ServiceExceptionIsEnabled()) { TD2.ServiceException(this.eventTraceActivity, activationException.ToString(), typeof(ServiceActivationException).FullName); } if (TD.ServiceActivationExceptionIsEnabled()) { TD.ServiceActivationException(activationException != null ? activationException.ToString() : string.Empty, activationException); } DiagnosticUtility.UnsafeEventLog.UnsafeLogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.WebHost, (uint)System.Runtime.Diagnostics.EventLogEventId.WebHostFailedToProcessRequest, true, TraceUtility.CreateSourceString(this), activationException.ToString()); }
void HandleRequest() { this.OriginalRequestUri = GetUrl(); string relativeVirtualPath; if (!string.IsNullOrEmpty(this.AspNetRouteServiceVirtualPath)) { relativeVirtualPath = this.AspNetRouteServiceVirtualPath; } else if (!string.IsNullOrEmpty(this.configurationBasedServiceVirtualPath)) { relativeVirtualPath = this.configurationBasedServiceVirtualPath; } else { relativeVirtualPath = GetAppRelativeCurrentExecutionFilePath(); } if (ensureWFService) { bool bypass = false; try { if (!ServiceHostingEnvironment.EnsureWorkflowService(relativeVirtualPath)) { CompleteOperation(null); bypass = true; return; } } finally { if (!bypass) { CompleteRequest(); } } } // Support for Cassini. if (ServiceHostingEnvironment.IsSimpleApplicationHost) { HostedTransportConfigurationManager.EnsureInitializedForSimpleApplicationHost(this); } HttpHostedTransportConfiguration transportConfiguration = HostedTransportConfigurationManager.GetConfiguration(this.OriginalRequestUri.Scheme) as HttpHostedTransportConfiguration; HostedHttpTransportManager transportManager = null; // There must be a transport binding that matches the request. if (transportConfiguration != null) { transportManager = transportConfiguration.GetHttpTransportManager(this.OriginalRequestUri); } if (transportManager == null) { InvalidOperationException invalidOpException = new InvalidOperationException(SR.Hosting_TransportBindingNotFound(OriginalRequestUri.ToString())); ServiceActivationException activationException = new ServiceActivationException(invalidOpException.Message, invalidOpException); LogServiceActivationException(activationException); throw FxTrace.Exception.AsError(activationException); } this.RequestUri = new Uri(transportManager.ListenUri, this.OriginalRequestUri.PathAndQuery); Fx.Assert( object.ReferenceEquals(this.RequestUri.Scheme, Uri.UriSchemeHttp) || object.ReferenceEquals(this.RequestUri.Scheme, Uri.UriSchemeHttps), "Scheme must be Http or Https."); ServiceHostingEnvironment.EnsureServiceAvailableFast(relativeVirtualPath, this.eventTraceActivity); transportManager.HttpContextReceived(this); }
private void HandleRequest() { string aspNetRouteServiceVirtualPath; this.OriginalRequestUri = this.GetUrl(); if (!string.IsNullOrEmpty(this.AspNetRouteServiceVirtualPath)) { aspNetRouteServiceVirtualPath = this.AspNetRouteServiceVirtualPath; } else if (!string.IsNullOrEmpty(this.configurationBasedServiceVirtualPath)) { aspNetRouteServiceVirtualPath = this.configurationBasedServiceVirtualPath; } else { aspNetRouteServiceVirtualPath = this.GetAppRelativeCurrentExecutionFilePath(); } if (this.ensureWFService) { bool flag = false; try { if (!ServiceHostingEnvironment.EnsureWorkflowService(aspNetRouteServiceVirtualPath)) { this.CompleteOperation(null); flag = true; return; } } finally { if (!flag) { this.CompleteRequest(); } } } if (ServiceHostingEnvironment.IsSimpleApplicationHost) { HostedTransportConfigurationManager.EnsureInitializedForSimpleApplicationHost(this); } HttpHostedTransportConfiguration configuration = HostedTransportConfigurationManager.GetConfiguration(this.OriginalRequestUri.Scheme) as HttpHostedTransportConfiguration; HostedHttpTransportManager httpTransportManager = null; if (configuration != null) { httpTransportManager = configuration.GetHttpTransportManager(this.OriginalRequestUri); } if (httpTransportManager == null) { InvalidOperationException innerException = new InvalidOperationException(System.ServiceModel.Activation.SR.Hosting_TransportBindingNotFound(this.OriginalRequestUri.ToString())); ServiceActivationException activationException = new ServiceActivationException(innerException.Message, innerException); this.LogServiceActivationException(activationException); throw System.ServiceModel.Activation.FxTrace.Exception.AsError(activationException); } this.RequestUri = new Uri(httpTransportManager.ListenUri, this.OriginalRequestUri.PathAndQuery); ServiceHostingEnvironment.EnsureServiceAvailableFast(aspNetRouteServiceVirtualPath); httpTransportManager.HttpContextReceived(this); }
private void LogServiceActivationException(ServiceActivationException activationException) { if (System.ServiceModel.Diagnostics.Application.TD.ServiceExceptionIsEnabled()) { System.ServiceModel.Diagnostics.Application.TD.ServiceException(activationException.ToString(), typeof(ServiceActivationException).FullName); } DiagnosticUtility.UnsafeEventLog.UnsafeLogEvent(TraceEventType.Error, EventLogCategory.WebHost, (System.ServiceModel.Diagnostics.EventLogEventId) (-1073610749), true, new string[] { System.ServiceModel.Activation.Diagnostics.TraceUtility.CreateSourceString(this), activationException.ToString() }); }
private static void LogServiceActivationException(ServiceActivationException exception) { if (exception.InnerException is HttpException) { string message = SafeTryGetHtmlErrorMessage((HttpException) exception.InnerException); if (string.IsNullOrEmpty(message)) { message = exception.Message; } DiagnosticUtility.UnsafeEventLog.UnsafeLogEvent(TraceEventType.Error, EventLogCategory.WebHost, (System.ServiceModel.Diagnostics.EventLogEventId) (-1073610750), true, new string[] { System.ServiceModel.Activation.Diagnostics.TraceUtility.CreateSourceString(hostingManager), message, exception.ToString() }); } else { DiagnosticUtility.UnsafeEventLog.UnsafeLogEvent(TraceEventType.Error, EventLogCategory.WebHost, (System.ServiceModel.Diagnostics.EventLogEventId) (-1073610749), true, new string[] { System.ServiceModel.Activation.Diagnostics.TraceUtility.CreateSourceString(hostingManager), exception.ToString() }); } if (System.ServiceModel.Diagnostics.Application.TD.ServiceExceptionIsEnabled()) { System.ServiceModel.Diagnostics.Application.TD.ServiceException(exception.ToString(), typeof(ServiceActivationException).FullName); } }