internal ServerProtocol Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, out bool abortProcessing)
        {
            ServerProtocol serverProtocol = null;

            abortProcessing = false;
            try {
                serverProtocol = CreateIfRequestCompatible(request);
                if (serverProtocol != null)
                {
                    serverProtocol.SetContext(type, context, request, response);
                }
                return(serverProtocol);
            }
            catch (Exception e) {
                abortProcessing = true;
                if (serverProtocol != null)
                {
                    // give the protocol a shot at handling the error in a custom way
                    if (!serverProtocol.WriteException(e, serverProtocol.Response.OutputStream))
                    {
                        throw new InvalidOperationException(Res.GetString(Res.UnableToHandleRequest0), e);
                    }
                }
                return(null);
            }
        }
        internal ServerProtocol Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, out bool abortProcessing)
        {
            ServerProtocol protocol = null;

            abortProcessing = false;
            protocol        = this.CreateIfRequestCompatible(request);
            try
            {
                if (protocol != null)
                {
                    protocol.SetContext(type, context, request, response);
                }
                return(protocol);
            }
            catch (Exception exception)
            {
                abortProcessing = true;
                if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException))
                {
                    throw;
                }
                if (Tracing.On)
                {
                    Tracing.ExceptionCatch(TraceEventType.Warning, this, "Create", exception);
                }
                if ((protocol != null) && !protocol.WriteException(exception, protocol.Response.OutputStream))
                {
                    throw new InvalidOperationException(Res.GetString("UnableToHandleRequest0"), exception);
                }
                return(null);
            }
        }
        void WriteException(Exception e)
        {
            if (this.wroteException)
            {
                return;
            }

            if (CompModSwitches.Remote.TraceVerbose)
            {
                Debug.WriteLine("Server Exception: " + e.ToString());
            }
            if (e is TargetInvocationException)
            {
                if (CompModSwitches.Remote.TraceVerbose)
                {
                    Debug.WriteLine("TargetInvocationException caught.");
                }
                e = e.InnerException;
            }

            this.wroteException = protocol.WriteException(e, protocol.Response.OutputStream);
            if (!this.wroteException)
            {
                throw e;
            }
        }
Esempio n. 4
0
        internal ServerProtocol Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, out bool abortProcessing)
        {
            ServerProtocol serverProtocol = null;

            abortProcessing = false;
            serverProtocol  = CreateIfRequestCompatible(request);
            try {
                if (serverProtocol != null)
                {
                    serverProtocol.SetContext(type, context, request, response);
                }
                return(serverProtocol);
            }
            catch (Exception e) {
                abortProcessing = true;
                if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException)
                {
                    throw;
                }
                if (Tracing.On)
                {
                    Tracing.ExceptionCatch(TraceEventType.Warning, this, "Create", e);
                }
                if (serverProtocol != null)
                {
                    // give the protocol a shot at handling the error in a custom way
                    if (!serverProtocol.WriteException(e, serverProtocol.Response.OutputStream))
                    {
                        throw new InvalidOperationException(Res.GetString(Res.UnableToHandleRequest0), e);
                    }
                }
                return(null);
            }
        }