System.Web.HttpServerUtility.Execute C# (CSharp) Method

Execute() private method

private Execute ( IHttpHandler handler, TextWriter writer, bool preserveForm, string exePath, string queryString, bool isTransfer, bool isInclude ) : void
handler IHttpHandler
writer System.IO.TextWriter
preserveForm bool
exePath string
queryString string
isTransfer bool
isInclude bool
return void
		internal void Execute (IHttpHandler handler, TextWriter writer, bool preserveForm, string exePath, string queryString, bool isTransfer, bool isInclude) {
#if NET_2_0 && !TARGET_J2EE
			// If the target handler is not Page, the transfer must not occur.
			// InTransit == true means we're being called from Transfer
			bool is_static = (handler is StaticFileHandler);
			if (isTransfer && !(handler is Page) && !is_static)
				throw new HttpException ("Transfer is only allowed to .aspx and static files");
#endif

			HttpRequest request = context.Request;
			string oldQuery = request.QueryStringRaw;
			if (queryString != null) {
				request.QueryStringRaw = queryString;
			} else if (!preserveForm) {
				request.QueryStringRaw = String.Empty;
			}

			HttpResponse response = context.Response;
			WebROCollection oldForm = request.Form as WebROCollection;
			if (!preserveForm) {
				request.SetForm (new WebROCollection ());
			}

			TextWriter output = writer;
			if (output == null)
			 	output = response.Output;
			
			TextWriter previous = response.SetTextWriter (output);
			string oldExePath = request.CurrentExecutionFilePath;
			bool oldIsInclude = context.IsProcessingInclude;
			try {
#if NET_2_0
				context.PushHandler (handler);
				if (is_static) // Not sure if this should apply to Page too
					request.SetFilePath (exePath);
#endif
				request.SetCurrentExePath (exePath);
				context.IsProcessingInclude = isInclude;
				
				if (!(handler is IHttpAsyncHandler)) {
					handler.ProcessRequest (context);
				} else {
					IHttpAsyncHandler asyncHandler = (IHttpAsyncHandler) handler;
					IAsyncResult ar = asyncHandler.BeginProcessRequest (context, null, null);
					WaitHandle asyncWaitHandle = ar != null ? ar.AsyncWaitHandle : null;
					if (asyncWaitHandle != null)
						asyncWaitHandle.WaitOne ();
					asyncHandler.EndProcessRequest (ar);
				}
			} finally {
				if (oldQuery != request.QueryStringRaw) {
					if (oldQuery != null && oldQuery.Length > 0) {
						oldQuery = oldQuery.Substring (1); // Ignore initial '?'
						request.QueryStringRaw = oldQuery; // which is added here.
					} else
						request.QueryStringRaw = String.Empty;
				}
				
				response.SetTextWriter (previous);
				if (!preserveForm)
					request.SetForm (oldForm);
#if NET_2_0
				context.PopHandler ();
#endif
				request.SetCurrentExePath (oldExePath);
				context.IsProcessingInclude = oldIsInclude;
			}
		}

Same methods

HttpServerUtility::Execute ( IHttpHandler handler, TextWriter writer, bool preserveForm ) : void
HttpServerUtility::Execute ( string path ) : void
HttpServerUtility::Execute ( string path, TextWriter writer ) : void
HttpServerUtility::Execute ( string path, TextWriter writer, bool preserveForm ) : void
HttpServerUtility::Execute ( string path, TextWriter writer, bool preserveForm, bool isTransfer ) : void
HttpServerUtility::Execute ( string path, bool preserveForm ) : void

Usage Example

Example #1
0
 public override void Execute(string path)
 {
     w.Execute(path);
 }
All Usage Examples Of System.Web.HttpServerUtility::Execute