2 // System.Web.HttpApplication
\r
5 // Patrik Torstensson (ptorsten@hotmail.com)
\r
6 // Tim Coleman (tim@timcoleman.com)
\r
7 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
\r
10 using System.Collections;
\r
11 using System.ComponentModel;
\r
12 using System.Threading;
\r
13 using System.Security.Principal;
\r
14 using System.Runtime.Remoting.Messaging;
\r
15 using System.Web.UI;
\r
16 using System.Web.Configuration;
\r
17 using System.Web.SessionState;
\r
19 namespace System.Web {
\r
22 public class HttpApplication : IHttpAsyncHandler, IHttpHandler, IComponent, IDisposable {
\r
24 #region Event Handlers
\r
26 // Async event holders
\r
27 AsyncEvents _acquireRequestStateAsync;
\r
28 AsyncEvents _authenticateRequestAsync;
\r
29 AsyncEvents _endRequestAsync;
\r
30 AsyncEvents _beginRequestAsync;
\r
31 AsyncEvents _authorizeRequestAsync;
\r
32 AsyncEvents _updateRequestCacheAsync;
\r
33 AsyncEvents _resolveRequestCacheAsync;
\r
34 AsyncEvents _releaseRequestStateAsync;
\r
35 AsyncEvents _preRequestHandlerExecuteAsync;
\r
36 AsyncEvents _postRequestHandlerExecuteAsync;
\r
38 // ID objects used to indentify the event
\r
39 static object AcquireRequestStateId = new Object();
\r
40 static object AuthenticateRequestId = new Object();
\r
41 static object EndRequestId = new Object();
\r
42 static object DisposedId = new Object();
\r
43 static object BeginRequestId = new Object();
\r
44 static object AuthorizeRequestId = new Object();
\r
45 static object UpdateRequestCacheId = new Object();
\r
46 static object ResolveRequestCacheId = new Object();
\r
47 static object ReleaseRequestStateId = new Object();
\r
48 static object PreSendRequestContentId = new Object();
\r
49 static object PreSendRequestHeadersId = new Object();
\r
50 static object PreRequestHandlerExecuteId = new Object();
\r
51 static object PostRequestHandlerExecuteId = new Object();
\r
52 static object ErrorId = new Object();
\r
55 private EventHandlerList _Events;
\r
57 public event EventHandler AcquireRequestState {
\r
58 add { Events.AddHandler(AcquireRequestStateId, value); }
\r
59 remove { Events.RemoveHandler(AcquireRequestStateId, value); }
\r
62 public event EventHandler AuthenticateRequest {
\r
63 add { Events.AddHandler(AuthenticateRequestId, value); }
\r
64 remove { Events.RemoveHandler(AuthenticateRequestId, value); }
\r
67 public event EventHandler AuthorizeRequest {
\r
68 add { Events.AddHandler(AuthorizeRequestId, value); }
\r
69 remove { Events.RemoveHandler(AuthorizeRequestId, value); }
\r
72 public event EventHandler BeginRequest {
\r
73 add { Events.AddHandler(BeginRequestId, value); }
\r
74 remove { Events.RemoveHandler(BeginRequestId, value); }
\r
77 public event EventHandler Disposed {
\r
78 add { Events.AddHandler(DisposedId, value); }
\r
79 remove { Events.RemoveHandler(DisposedId, value); }
\r
82 public event EventHandler EndRequest {
\r
83 add { Events.AddHandler(EndRequestId, value); }
\r
84 remove { Events.RemoveHandler(EndRequestId, value); }
\r
87 public event EventHandler Error {
\r
88 add { Events.AddHandler(ErrorId, value); }
\r
89 remove { Events.RemoveHandler(ErrorId, value); }
\r
92 public event EventHandler PostRequestHandlerExecute {
\r
93 add { Events.AddHandler(PostRequestHandlerExecuteId, value); }
\r
94 remove { Events.RemoveHandler(PostRequestHandlerExecuteId, value); }
\r
97 public event EventHandler PreRequestHandlerExecute {
\r
98 add { Events.AddHandler(PreRequestHandlerExecuteId, value); }
\r
99 remove { Events.RemoveHandler(PreRequestHandlerExecuteId, value); }
\r
102 public event EventHandler PreSendRequestContent {
\r
103 add { Events.AddHandler(PreSendRequestContentId, value); }
\r
104 remove { Events.RemoveHandler(PreSendRequestContentId, value); }
\r
107 public event EventHandler ReleaseRequestState {
\r
108 add { Events.AddHandler(ReleaseRequestStateId, value); }
\r
109 remove { Events.RemoveHandler(ReleaseRequestStateId, value); }
\r
112 public event EventHandler ResolveRequestCache {
\r
113 add { Events.AddHandler(ResolveRequestCacheId, value); }
\r
114 remove { Events.RemoveHandler(ResolveRequestCacheId, value); }
\r
117 public event EventHandler UpdateRequestCache {
\r
118 add { Events.AddHandler(UpdateRequestCacheId, value); }
\r
119 remove { Events.RemoveHandler(UpdateRequestCacheId, value); }
\r
122 public event EventHandler PreSendRequestHeaders
\r
125 Events.AddHandler (PreSendRequestHeadersId, value);
\r
128 Events.RemoveHandler (PreSendRequestHeadersId, value);
\r
132 public void AddOnAcquireRequestStateAsync(BeginEventHandler beg, EndEventHandler end) {
\r
133 if (null == _acquireRequestStateAsync)
\r
134 _acquireRequestStateAsync = new AsyncEvents();
\r
136 _acquireRequestStateAsync.Add(beg, end);
\r
139 public void AddOnAuthenticateRequestAsync(BeginEventHandler beg, EndEventHandler end) {
\r
140 if (null == _authenticateRequestAsync)
\r
141 _authenticateRequestAsync = new AsyncEvents();
\r
143 _authenticateRequestAsync.Add(beg, end);
\r
146 public void AddOnAuthorizeRequestAsync(BeginEventHandler beg, EndEventHandler end) {
\r
147 if (null == _authorizeRequestAsync)
\r
148 _authorizeRequestAsync= new AsyncEvents();
\r
150 _authorizeRequestAsync.Add(beg, end);
\r
153 public void AddOnBeginRequestAsync(BeginEventHandler beg, EndEventHandler end) {
\r
154 if (null == _beginRequestAsync)
\r
155 _beginRequestAsync = new AsyncEvents();
\r
157 _beginRequestAsync.Add(beg, end);
\r
160 public void AddOnEndRequestAsync(BeginEventHandler beg, EndEventHandler end) {
\r
161 if (null == _endRequestAsync)
\r
162 _endRequestAsync = new AsyncEvents();
\r
164 _endRequestAsync.Add(beg, end);
\r
167 public void AddOnPostRequestHandlerExecuteAsync(BeginEventHandler beg, EndEventHandler end) {
\r
168 if (null == _postRequestHandlerExecuteAsync)
\r
169 _postRequestHandlerExecuteAsync = new AsyncEvents();
\r
171 _postRequestHandlerExecuteAsync.Add(beg, end);
\r
174 public void AddOnPreRequestHandlerExecuteAsync(BeginEventHandler beg, EndEventHandler end) {
\r
175 if (null == _preRequestHandlerExecuteAsync)
\r
176 _preRequestHandlerExecuteAsync = new AsyncEvents();
\r
178 _preRequestHandlerExecuteAsync.Add(beg, end);
\r
181 public void AddOnReleaseRequestStateAsync(BeginEventHandler beg, EndEventHandler end) {
\r
182 if (null == _releaseRequestStateAsync)
\r
183 _releaseRequestStateAsync = new AsyncEvents();
\r
185 _releaseRequestStateAsync.Add(beg, end);
\r
188 public void AddOnResolveRequestCacheAsync(BeginEventHandler beg, EndEventHandler end) {
\r
189 if (null == _resolveRequestCacheAsync)
\r
190 _resolveRequestCacheAsync = new AsyncEvents();
\r
192 _resolveRequestCacheAsync.Add(beg, end);
\r
195 public void AddOnUpdateRequestCacheAsync(BeginEventHandler beg, EndEventHandler end) {
\r
196 if (null == _updateRequestCacheAsync)
\r
197 _updateRequestCacheAsync = new AsyncEvents();
\r
199 _updateRequestCacheAsync.Add(beg, end);
\r
204 #region State Machine
\r
206 interface IStateHandler {
\r
209 bool CompletedSynchronously {
\r
213 bool PossibleToTimeout {
\r
219 class EventState : IStateHandler {
\r
220 private HttpApplication _app;
\r
221 private EventHandler _event;
\r
223 public EventState(HttpApplication app, EventHandler evt) {
\r
228 public void Execute() {
\r
229 if (null != _event) {
\r
230 _event(_app, EventArgs.Empty);
\r
234 public bool CompletedSynchronously {
\r
240 public bool PossibleToTimeout {
\r
247 class AsyncEventState : IStateHandler {
\r
248 private HttpApplication _app;
\r
249 private BeginEventHandler _begin;
\r
250 private EndEventHandler _end;
\r
251 private AsyncCallback _callback;
\r
252 private bool _async;
\r
254 public AsyncEventState(HttpApplication app, BeginEventHandler begin, EndEventHandler end) {
\r
259 _callback = new AsyncCallback(OnAsyncReady);
\r
262 public void Execute() {
\r
264 IAsyncResult ar = _begin(_app, EventArgs.Empty, _callback, null);
\r
265 if (ar.CompletedSynchronously) {
\r
271 public bool CompletedSynchronously {
\r
277 public bool PossibleToTimeout {
\r
279 // We can't cancel a async event
\r
284 private void OnAsyncReady(IAsyncResult ar) {
\r
285 if (ar.CompletedSynchronously) return;
\r
287 Exception error = null;
\r
290 // Invoke end handler
\r
293 catch (System.Exception exc) {
\r
294 // Flow this error to the next state (handle during state execution)
\r
298 _app._state.ExecuteNextAsync(error);
\r
302 class AsyncEvents {
\r
303 private ArrayList _events;
\r
304 private class EventRecord {
\r
305 public EventRecord(BeginEventHandler beg, EndEventHandler end) {
\r
310 public BeginEventHandler Begin;
\r
311 public EndEventHandler End;
\r
314 public AsyncEvents() {
\r
315 _events = new ArrayList();
\r
318 public void Add(BeginEventHandler begin, EndEventHandler end) {
\r
319 _events.Add(new EventRecord(begin, end));
\r
322 public void GetAsStates(HttpApplication app, ArrayList states) {
\r
323 foreach (object obj in _events) {
\r
324 states.Add(new AsyncEventState(app, ((EventRecord) obj).Begin, ((EventRecord) obj).End));
\r
330 class ExecuteHandlerState : IStateHandler {
\r
331 private HttpApplication _app;
\r
332 private AsyncCallback _callback;
\r
333 private IHttpAsyncHandler _handler;
\r
334 private bool _async;
\r
336 public ExecuteHandlerState(HttpApplication app) {
\r
338 _callback = new AsyncCallback(OnAsyncReady);
\r
341 private void OnAsyncReady(IAsyncResult ar) {
\r
342 if (ar.CompletedSynchronously) return;
\r
344 Exception error = null;
\r
347 // Invoke end handler
\r
348 _handler.EndProcessRequest(ar);
\r
350 catch (System.Exception exc) {
\r
351 // Flow this error to the next state (handle during state execution)
\r
356 _app._state.ExecuteNextAsync(error);
\r
359 public void Execute() {
\r
360 IHttpHandler handler = _app.Context.Handler;
\r
361 if (null != handler) {
\r
362 // Check if we can execute async
\r
363 if (handler is IHttpAsyncHandler) {
\r
365 _handler = (IHttpAsyncHandler) handler;
\r
367 IAsyncResult ar = _handler.BeginProcessRequest(_app.Context, _callback, null);
\r
368 if (ar.CompletedSynchronously) {
\r
371 ((IHttpAsyncHandler) handler).EndProcessRequest(ar);
\r
377 handler.ProcessRequest( _app.Context);
\r
382 public bool CompletedSynchronously {
\r
388 public bool PossibleToTimeout {
\r
390 if (_app.Context.Handler is IHttpAsyncHandler)
\r
399 class CreateHandlerState : IStateHandler {
\r
400 private HttpApplication _app;
\r
402 public CreateHandlerState(HttpApplication app) {
\r
406 public void Execute() {
\r
407 _app.Context.Handler = _app.CreateHttpHandler ( _app.Context,
\r
408 _app.Request.RequestType,
\r
409 _app.Request.FilePath,
\r
410 _app.Request.PhysicalPath);
\r
413 public bool CompletedSynchronously {
\r
419 public bool PossibleToTimeout {
\r
426 class FilterHandlerState : IStateHandler {
\r
427 private HttpApplication _app;
\r
429 public FilterHandlerState(HttpApplication app) {
\r
433 public void Execute() {
\r
434 _app.Context.Response.DoFilter();
\r
437 public bool CompletedSynchronously {
\r
443 public bool PossibleToTimeout {
\r
450 class StateMachine {
\r
451 private HttpApplication _app;
\r
452 private WaitCallback _asynchandler;
\r
454 private IStateHandler [] _handlers;
\r
455 private int _currentStateIdx;
\r
456 private int _endStateIdx;
\r
457 private int _countSteps;
\r
458 private int _countSyncSteps;
\r
460 // Helper to create the states for a normal event
\r
461 private void GetAsStates(object Event, ArrayList states) {
\r
462 // Get list of clients for the sync events
\r
463 Delegate evnt = _app.Events[Event];
\r
464 if (null != evnt) {
\r
465 System.Delegate [] clients = evnt.GetInvocationList();
\r
467 foreach (Delegate client in clients) {
\r
468 states.Add(new EventState(_app, (EventHandler) client));
\r
473 internal StateMachine(HttpApplication app) {
\r
477 internal void Init() {
\r
478 _asynchandler = new WaitCallback(OnAsyncCallback);
\r
480 // Create a arraylist of states to execute
\r
481 ArrayList states = new ArrayList();
\r
484 if (null != _app._beginRequestAsync)
\r
485 _app._beginRequestAsync.GetAsStates(_app, states);
\r
486 GetAsStates(HttpApplication.BeginRequestId, states);
\r
488 // AuthenticateRequest
\r
489 if (null != _app._authenticateRequestAsync)
\r
490 _app._authenticateRequestAsync.GetAsStates(_app, states);
\r
491 GetAsStates(HttpApplication.AuthenticateRequestId, states);
\r
493 // AuthorizeRequest
\r
494 if (null != _app._authorizeRequestAsync)
\r
495 _app._authorizeRequestAsync.GetAsStates(_app, states);
\r
496 GetAsStates(HttpApplication.AuthorizeRequestId, states);
\r
498 // ResolveRequestCache
\r
499 if (null != _app._resolveRequestCacheAsync)
\r
500 _app._resolveRequestCacheAsync.GetAsStates(_app, states);
\r
501 GetAsStates(HttpApplication.ResolveRequestCacheId, states);
\r
503 // [A handler (a page corresponding to the request URL) is created at this point.]
\r
504 states.Add(new CreateHandlerState(_app));
\r
506 // AcquireRequestState
\r
507 if (null != _app._acquireRequestStateAsync)
\r
508 _app._acquireRequestStateAsync.GetAsStates(_app, states);
\r
509 GetAsStates(HttpApplication.AcquireRequestStateId, states);
\r
511 // PreRequestHandlerExecute
\r
512 if (null != _app._preRequestHandlerExecuteAsync)
\r
513 _app._preRequestHandlerExecuteAsync.GetAsStates(_app, states);
\r
514 GetAsStates(HttpApplication.PreRequestHandlerExecuteId, states);
\r
516 // [The handler is executed.]
\r
517 states.Add(new ExecuteHandlerState(_app));
\r
519 // PostRequestHandlerExecute
\r
520 if (null != _app._postRequestHandlerExecuteAsync)
\r
521 _app._postRequestHandlerExecuteAsync.GetAsStates(_app, states);
\r
522 GetAsStates(HttpApplication.PostRequestHandlerExecuteId, states);
\r
524 // ReleaseRequestState
\r
525 if (null != _app._releaseRequestStateAsync)
\r
526 _app._releaseRequestStateAsync.GetAsStates(_app, states);
\r
527 GetAsStates(HttpApplication.ReleaseRequestStateId, states);
\r
529 // [Response filters, if any, filter the output.]
\r
530 states.Add(new FilterHandlerState(_app));
\r
532 // UpdateRequestCache
\r
533 if (null != _app._updateRequestCacheAsync)
\r
534 _app._updateRequestCacheAsync.GetAsStates(_app, states);
\r
535 GetAsStates(HttpApplication.UpdateRequestCacheId, states);
\r
538 if (null != _app._updateRequestCacheAsync)
\r
539 _app._updateRequestCacheAsync.GetAsStates(_app, states);
\r
540 GetAsStates(HttpApplication.EndRequestId, states);
\r
542 // Make list ready to execute
\r
543 _handlers = new IStateHandler[states.Count];
\r
544 states.CopyTo(_handlers);
\r
548 internal void Reset() {
\r
549 _countSyncSteps = 0;
\r
551 _currentStateIdx = -1;
\r
552 _endStateIdx = _handlers.Length - 1;
\r
555 internal void Start() {
\r
557 ExecuteNextAsync(null);
\r
560 internal void ExecuteNextAsync(Exception lasterror) {
\r
561 //FIXME: something is wrong with this: the socket is closed before compilation finishes.
\r
562 // if (!Thread.CurrentThread.IsThreadPoolThread) {
\r
563 // ThreadPool.QueueUserWorkItem(_asynchandler, lasterror);
\r
565 ExecuteNext(lasterror);
\r
569 private void ExecuteNext(Exception lasterror) {
\r
570 bool ready_sync = false;
\r
571 IStateHandler handler;
\r
574 _app.OnStateExecuteEnter();
\r
577 if (null != lasterror)
\r
578 _app.HandleError(lasterror);
\r
580 // Check if request flow is to be stopped
\r
581 if (_app._CompleteRequest)
\r
582 _currentStateIdx = _endStateIdx;
\r
584 // Get next state handler
\r
585 if (_currentStateIdx < _endStateIdx) {
\r
586 _currentStateIdx++;
\r
587 handler = _handlers[_currentStateIdx];
\r
590 lasterror = ExecuteState(handler, ref ready_sync);
\r
594 } while (ready_sync && _currentStateIdx < _endStateIdx);
\r
597 _app.OnStateExecuteLeave();
\r
601 // Finish the request off..
\r
602 if (_currentStateIdx == _endStateIdx) {
\r
603 _app._asyncWebResult.Complete((_countSyncSteps == _countSteps), null, null);
\r
604 _app.Context.Handler = null;
\r
605 _app.Context.ApplicationInstance = null;
\r
606 _app.RecycleHandlers();
\r
607 _app._asyncWebResult = null;
\r
609 HttpApplicationFactory.RecycleInstance(_app);
\r
613 private void OnAsyncCallback(object obj) {
\r
614 ExecuteNext((Exception) obj);
\r
618 private Exception ExecuteState(IStateHandler state, ref bool readysync) {
\r
619 Exception lasterror = null;
\r
623 if (state.PossibleToTimeout) {
\r
624 // TODO: Start timeout possible
\r
629 // TODO: end timeout possible
\r
632 // Check if we have a timeout and wait for the exception.
\r
637 if (state.CompletedSynchronously)
\r
643 catch (System.Exception obj) {
\r
647 catch (System.Threading.ThreadAbortException obj) {
\r
650 // handle request timeout and return timeout httpexception
\r
661 private StateMachine _state;
\r
663 private bool _CompleteRequest;
\r
664 private HttpContext _Context;
\r
665 private Exception _lastError;
\r
667 private HttpContext _savedContext;
\r
668 private IPrincipal _savedUser;
\r
669 private HttpAsyncResult _asyncWebResult;
\r
671 private ISite _Site;
\r
672 private HttpModuleCollection _ModuleCollection;
\r
673 private HttpSessionState _Session;
\r
674 private HttpApplicationState _appState;
\r
676 private bool _InPreRequestResponseMode;
\r
679 #region Constructor
\r
680 public HttpApplication() {
\r
685 private IHttpHandler CreateHttpHandler (HttpContext context, string type, string file, string path)
\r
687 HandlerFactoryConfiguration handler = HttpContext.GetAppConfig ("system.web/httpHandlers")
\r
688 as HandlerFactoryConfiguration;
\r
689 if (handler == null)
\r
690 throw new HttpException ("Cannot get system.web/httpHandlers handler.");
\r
692 return (IHttpHandler) handler.FindHandler (type, path).Create ();
\r
696 internal void RecycleHandlers() {
\r
697 // TODO: Recycle the created handlers (via factory?)
\r
700 internal void InitModules() {
\r
701 ModulesConfiguration modules;
\r
703 modules = (ModulesConfiguration) HttpContext.GetAppConfig("system.web/httpmodules");
\r
704 if (null == modules)
\r
705 throw new HttpException(HttpRuntime.FormatResourceString("missing_modules_config"));
\r
707 _ModuleCollection = modules.CreateCollection();
\r
708 if (null != _ModuleCollection) {
\r
711 count = _ModuleCollection.Count;
\r
712 for (pos = 0; pos != count; pos++) {
\r
713 ((IHttpModule) _ModuleCollection.Get(pos)).Init(this);
\r
718 internal void InitCulture() {
\r
719 // TODO: Read culture info from globalization from config
\r
722 internal void OnStateExecuteEnter() {
\r
723 // TODO: Set correct culture for the thread
\r
724 // TODO: Register in timeout manager
\r
726 _savedContext = HttpContext.Context;
\r
727 HttpContext.Context = _Context;
\r
729 _savedUser = System.Threading.Thread.CurrentPrincipal;
\r
730 System.Threading.Thread.CurrentPrincipal = Context.User;
\r
733 internal void OnStateExecuteLeave() {
\r
734 // TODO: Restore culture for the thread
\r
735 // TODO: Remove from timeout manager
\r
737 HttpContext.Context = _savedContext;
\r
738 if (null != _savedUser) {
\r
739 System.Threading.Thread.CurrentPrincipal = _savedUser;
\r
744 internal void ClearError() {
\r
748 internal void HandleError(Exception obj) {
\r
749 EventHandler handler;
\r
752 if (null != _Context) {
\r
753 if (null != _Context.Error)
\r
756 _Context.AddError(obj);
\r
758 if (null != _lastError)
\r
763 // Fire OnError event here
\r
764 handler = (EventHandler) Events[HttpApplication.ErrorId];
\r
765 if (null != handler) {
\r
767 handler(this, EventArgs.Empty);
\r
769 catch (Exception excp) {
\r
770 if (null != _Context)
\r
771 _Context.AddError(excp);
\r
778 internal void Startup(HttpContext context, HttpApplicationState state) {
\r
779 // TODO: Need to attach methods in global.asax to correct events
\r
780 _Context = context;
\r
783 _state = new StateMachine(this);
\r
785 // Initialize all IHttpModule(s)
\r
788 // Initialize custom application
\r
789 _InPreRequestResponseMode = true;
\r
793 catch (Exception obj) {
\r
797 _InPreRequestResponseMode = false;
\r
802 internal void Cleanup() {
\r
806 catch (Exception obj) {
\r
810 if (null != _ModuleCollection) {
\r
812 int count = _ModuleCollection.Count;
\r
814 for (pos = 0; pos != count; pos++) {
\r
815 ((IHttpModule) _ModuleCollection.Get(pos)).Dispose();
\r
818 _ModuleCollection = null;
\r
824 public void CompleteRequest() {
\r
825 _CompleteRequest = true;
\r
828 public virtual void Dispose() {
\r
830 EventHandler disposed = (EventHandler) Events[HttpApplication.DisposedId];
\r
831 if (null != disposed)
\r
832 disposed(this, EventArgs.Empty);
\r
835 public virtual void Init() {
\r
838 public virtual string GetVaryByCustomString(HttpContext context, string custom) {
\r
839 if (custom.ToLower() == "browser") {
\r
840 return context.Request.Browser.Type;
\r
846 IAsyncResult IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) {
\r
847 _Context = context;
\r
848 Context.ApplicationInstance = this;
\r
849 _CompleteRequest = false;
\r
851 _asyncWebResult = new HttpAsyncResult(cb, extraData);
\r
855 return _asyncWebResult;
\r
858 void IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) {
\r
859 HttpAsyncResult ar = (HttpAsyncResult) result;
\r
861 if (null != ar.Error)
\r
865 void IHttpHandler.ProcessRequest(HttpContext context) {
\r
866 throw new NotSupportedException(HttpRuntime.FormatResourceString("sync_not_supported"));
\r
869 bool IHttpHandler.IsReusable {
\r
878 [Browsable (false)]
\r
879 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
\r
880 public HttpApplicationState Application {
\r
882 return HttpApplicationFactory.ApplicationState;
\r
886 [Browsable (false)]
\r
887 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
\r
888 public HttpContext Context {
\r
894 protected EventHandlerList Events {
\r
896 if (null == _Events) {
\r
897 _Events = new EventHandlerList();
\r
904 [Browsable (false)]
\r
905 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
\r
906 public HttpModuleCollection Modules {
\r
908 if (null == _ModuleCollection) {
\r
909 _ModuleCollection = new HttpModuleCollection();
\r
912 return _ModuleCollection;
\r
916 [Browsable (false)]
\r
917 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
\r
918 public HttpRequest Request {
\r
920 if (null != _Context && (!_InPreRequestResponseMode)) {
\r
921 return _Context.Request;
\r
924 throw new HttpException("Can't get request object");
\r
928 [Browsable (false)]
\r
929 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
\r
930 public HttpResponse Response {
\r
932 if (null != _Context && (!_InPreRequestResponseMode)) {
\r
933 return _Context.Response;
\r
936 throw new HttpException("Can't get response object");
\r
940 [Browsable (false)]
\r
941 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
\r
942 public HttpServerUtility Server {
\r
944 if (null != _Context) {
\r
945 return _Context.Server;
\r
948 return new HttpServerUtility(this);
\r
952 [Browsable (false)]
\r
953 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
\r
954 public HttpSessionState Session {
\r
956 if (null != _Session) {
\r
960 if (null != _Context && null != _Context.Session) {
\r
961 return _Context.Session;
\r
964 throw new HttpException("Failed to get session object");
\r
968 [Browsable (false)]
\r
969 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
\r
970 public IPrincipal User {
\r
972 return _Context.User;
\r
976 [Browsable (false)]
\r
977 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
\r
978 public ISite Site {
\r
987 #endregion Properties
\r