Beispiel #1
0
        private void InitModules(NetHttpWorkerRequest wr)
        {
            var wrAsWebHost = (wr as WebHostWorkerRequest);

            if (wrAsWebHost == null)
            {
                throw new InvalidOperationException();
            }
            var webHostRuntime = wrAsWebHost.WebHostRuntime;

            if (webHostRuntime == null)
            {
                throw new InvalidOperationException();
            }
            _moduleCollection = webHostRuntime.Modules;
            //
            int count = _moduleCollection.Count;

            for (int index = 0; index < count; index++)
            {
                _currentModuleCollectionKey = _moduleCollection.GetKey(index);
                _moduleCollection[index].Init(this);
            }
            _currentModuleCollectionKey = null;
            InitAppLevelCulture();
        }
Beispiel #2
0
        private void EndOfSendCallback(NetHttpWorkerRequest wr, object arg)
        {
            var context = (NetHttpContext)arg;

            ((NetHttpRequest)context.Request).Dispose();
            ((NetHttpResponse)context.Response).Dispose();
        }
Beispiel #3
0
        internal NetHttpApplication GetApplicationInstance(NetHttpWorkerRequest wr, NetHttpContext context)
        {
            EnsureInited();
            EnsureAppStartCalled(context);
            //
            NetHttpApplication application = null;

            lock (_freeInstances)
                if (_numFreeInstances > 0)
                {
                    application = (NetHttpApplication)_freeInstances.Pop();
                    _numFreeInstances--;
                }
            if (application == null)
            {
                application = (NetHttpApplication)NetHttpRuntime.CreateNonPublicInstance(_applicationType, null);
                application.InitInternal(wr, context, _state, this, _eventHandlerMethods);
            }
            return(application);
        }
Beispiel #4
0
 internal void InitInternal(NetHttpWorkerRequest wr, NetHttpContext context, NetHttpApplicationState state, NetHttpApplicationFactory factory, MethodInfo[] handlers)
 {
     _state   = state;
     _factory = factory;
     try
     {
         _initContext = context;
         _initContext.NetApplicationInstance = this;
         InitModules(wr);
         if (handlers != null)
         {
             HookupEventHandlersForApplicationAndModules(handlers);
         }
         _context = context;
         if (_context != null)
         {
             _context.HideRequestResponse = true;
         }
         _hideRequestResponse = true;
         try { Init(); }
         catch (Exception exception) { RecordError(exception); }
         if (_context != null)
         {
             _context.HideRequestResponse = false;
         }
         _hideRequestResponse     = false;
         _context                 = null;
         _resumeStepsWaitCallback = new WaitCallback(ResumeStepsWaitCallback);
         _stepManager             = new ApplicationNetStepManager(this);
         _stepManager.BuildSteps(_resumeStepsWaitCallback);
     }
     finally
     {
         _initInternalCompleted = true;
         _initContext.NetApplicationInstance = null;
         _initContext = null;
     }
 }
        private static void FinishRequest(WebHost host, NetHttpWorkerRequest wr, NetHttpContext context, Exception e)
        {
            var response = (NetHttpResponse)context.Response;

            if (e == null)
            {
                try { response.FinalFlushAtTheEndOfRequestProcessing(); }
                catch (Exception e2) { e = e2; }
            }
            if (e != null)
            {
                context.DisableCustomHttpEncoder = true;
                try
                {
                    try { response.ReportRuntimeError(e, true, false); }
                    catch (Exception e2) { response.ReportRuntimeError(e2, false, false); }
                    response.FinalFlushAtTheEndOfRequestProcessing();
                }
                catch { }
            }
            _firstRequestCompleted = true;
            int statusCode = response.StatusCode;

            //context.FinishRequestForCachedPathData(statusCode);
            try { wr.EndOfRequest(); }
            catch (Exception e3) { RaiseRuntimeError(e3, wr); }
            Console.WriteLine("d:Request");
            Interlocked.Decrement(ref host._activeRequests);
            if (WebHost.UseThreading)
            {
                if (host._requestQueue != null)
                {
                    host._requestQueue.ScheduleMoreWorkIfNeeded();
                }
            }
        }