internal static void DisposeHandler(HttpContext context, IntPtr nativeRequestContext, RequestNotificationStatus status) { if (UnsafeIISMethods.MgdCanDisposeManagedContext(nativeRequestContext, status)) { DisposeHandlerPrivate(context); } }
internal void Complete(bool synchronous, object result, Exception error, RequestNotificationStatus status) { this._completed = true; this._completedSynchronously = synchronous; this._result = result; this._error = error; this._status = status; if (this._callback != null) { this._callback(this); } }
internal HttpAsyncResult(AsyncCallback cb, object state, bool completed, object result, Exception error) { this._callback = cb; this._asyncState = state; this._completed = completed; this._completedSynchronously = completed; this._result = result; this._error = error; this._status = RequestNotificationStatus.Continue; if (this._completed && (this._callback != null)) { this._callback(this); } }
/* * Constructor with known result */ internal HttpAsyncResult(AsyncCallback cb, Object state, bool completed, Object result, Exception error) { _callback = cb; _asyncState = state; _completed = completed; _completedSynchronously = completed; _result = result; _error = error; _status = RequestNotificationStatus.Continue; if (_completed && _callback != null) _callback(this); }
public ReliableAsyncResult(ReliableAsyncCallback cb, object state, bool completed, string responseText, ReliableHttpException error) { _id = Guid.NewGuid(); _callback = cb; _asyncState = state; _completed = completed; _completedSynchronously = completed; ResponseText = responseText; _error = error; _status = RequestNotificationStatus.Continue; if (_completed && (_callback != null)) { _callback(this); } }
/* * Helper method to process completions */ internal void Complete(bool synchronous, Object result, Exception error, RequestNotificationStatus status) { if (Volatile.Read(ref _threadWhichStartedOperation) == Thread.CurrentThread) { // If we're calling Complete on the same thread which kicked off the operation, then // we ignore the 'synchronous' value that the caller provided to us since we know // for a fact that this is really a synchronous completion. This is only checked if // the caller calls the MarkCallToBeginMethod* routines below. synchronous = true; } _completed = true; _completedSynchronously = synchronous; _result = result; _error = error; _status = status; if (_callback != null) _callback(this); }
// if the context has an error, report it, but only one time internal void ReportRuntimeErrorIfExists(ref RequestNotificationStatus status) { Exception e = Error; if (e == null || _runtimeErrorReported) { return; } // WOS 1921799: custom errors don't work in integrated mode if there's an initialization exception if (_notificationContext != null && CurrentModuleIndex == -1) { try { IIS7WorkerRequest wr = _wr as IIS7WorkerRequest; if (Request.QueryString["aspxerrorpath"] != null && wr != null && String.IsNullOrEmpty(wr.GetManagedHandlerType()) && wr.GetCurrentModuleName() == PipelineRuntime.InitExceptionModuleName) { status = RequestNotificationStatus.Continue; // allow non-managed handler to execute request return; } } catch { } } _runtimeErrorReported = true; if (HttpRuntime.AppOfflineMessage != null) { try { // report app offline error Response.TrySkipIisCustomErrors = true; HttpRuntime.ReportAppOfflineErrorMessage(Response, HttpRuntime.AppOfflineMessage); } catch { } } else { // report error exception using (new DisposableHttpContextWrapper(this)) { // if the custom encoder throws, it might interfere with returning error information // to the client, so we force use of the default encoder DisableCustomHttpEncoder = true; // when application is on UNC share the code below must // be run while impersonating the token given by IIS using (new ApplicationImpersonationContext()) { try { try { // try to report error in a way that could possibly throw (a config exception) Response.ReportRuntimeError(e, true /*canThrow*/, false); } catch (Exception eReport) { // report the config error in a way that would not throw Response.ReportRuntimeError(eReport, false /*canThrow*/, false); } } catch (Exception) { } } } } status = RequestNotificationStatus.FinishRequest; return; }
/* * Constructor with pending result */ internal HttpAsyncResult(AsyncCallback cb, Object state) { _callback = cb; _asyncState = state; _status = RequestNotificationStatus.Continue; }
// called from managed code as a perf optimization to avoid calling back later internal static void DisposeHandler(HttpContext context, IntPtr nativeRequestContext, RequestNotificationStatus status) { if (IIS.MgdCanDisposeManagedContext(nativeRequestContext, status)) { context.RootedObjects.Destroy(); } }
internal void Complete(bool synchronous, string responseText, ReliableHttpException error, RequestNotificationStatus status) { _completed = true; _completedSynchronously = synchronous; ResponseText = responseText; _error = error; _status = status; if (_callback != null) { _callback(this); } }
internal void ReportRuntimeErrorIfExists(ref RequestNotificationStatus status) { Exception error = this.Error; if ((error == null) || this._runtimeErrorReported) { return; } if ((this._notificationContext != null) && (this.CurrentModuleIndex == -1)) { try { IIS7WorkerRequest request = this._wr as IIS7WorkerRequest; if (((this.Request.QueryString["aspxerrorpath"] != null) && (request != null)) && (string.IsNullOrEmpty(request.GetManagedHandlerType()) && (request.GetCurrentModuleName() == "AspNetInitializationExceptionModule"))) { status = RequestNotificationStatus.Continue; return; } } catch { } } this._runtimeErrorReported = true; if (HttpRuntime.AppOfflineMessage != null) { try { this.Response.TrySkipIisCustomErrors = true; HttpRuntime.ReportAppOfflineErrorMessage(this.Response, HttpRuntime.AppOfflineMessage); goto Label_00FA; } catch { goto Label_00FA; } } using (new DisposableHttpContextWrapper(this)) { this.DisableCustomHttpEncoder = true; using (new ApplicationImpersonationContext()) { try { try { this.Response.ReportRuntimeError(error, true, false); } catch (Exception exception2) { this.Response.ReportRuntimeError(exception2, false, false); } } catch (Exception) { } } } Label_00FA: status = RequestNotificationStatus.FinishRequest; }
private void FinishRequestNotification(IIS7WorkerRequest wr, HttpContext context, ref RequestNotificationStatus status) { HttpApplication applicationInstance = context.ApplicationInstance; if (context.NotificationContext.RequestCompleted) status = RequestNotificationStatus.FinishRequest; context.ReportRuntimeErrorIfExists(ref status); if (status == RequestNotificationStatus.FinishRequest && (context.CurrentNotification == RequestNotification.LogRequest || context.CurrentNotification == RequestNotification.EndRequest)) status = RequestNotificationStatus.Continue; IntPtr requestContext = wr.RequestContext; bool sendHeaders = UnsafeIISMethods.MgdIsLastNotification(requestContext, status); try { context.Response.UpdateNativeResponse(sendHeaders); } catch (Exception ex) { wr.UnlockCachedResponseBytes(); context.AddError(ex); context.ReportRuntimeErrorIfExists(ref status); context.Response.UpdateNativeResponse(sendHeaders); } if (sendHeaders) context.FinishPipelineRequest(); if (status == RequestNotificationStatus.Pending) return; PipelineRuntime.DisposeHandler(context, requestContext, status); }