当前位置: 首页>>代码示例>>C#>>正文


C# IHttpHandler.ProcessRequest方法代码示例

本文整理汇总了C#中IHttpHandler.ProcessRequest方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpHandler.ProcessRequest方法的具体用法?C# IHttpHandler.ProcessRequest怎么用?C# IHttpHandler.ProcessRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHttpHandler的用法示例。


在下文中一共展示了IHttpHandler.ProcessRequest方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VerifyAndProcessRequest

        // synchronous code
        protected override void VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext) {
            if (httpHandler == null) {
                throw new ArgumentNullException("httpHandler");
            }

            httpHandler.ProcessRequest(HttpContext.Current);
        }
开发者ID:nobled,项目名称:mono,代码行数:8,代码来源:MvcHttpHandler.cs

示例2: VerifyAndProcessRequest

		protected override void VerifyAndProcessRequest(IHttpHandler handler, HttpContextBase context)
		{
			Precondition.Require(handler, () => Error.ArgumentNull("handler"));
			Precondition.Require(context, () => Error.ArgumentNull("context"));

			handler.ProcessRequest(context.Unwrap());
		}
开发者ID:radischevo,项目名称:Radischevo.Wahha,代码行数:7,代码来源:MvcHttpHandler.cs

示例3: VerifyAndProcessRequest

 protected override void VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext)
 {
     if (httpHandler == null) {
         throw new ArgumentNullException("httpHandler");
     }
     var origHttpHandler = httpContext.Handler;
     try {
         httpContext.Handler = httpHandler;
         httpHandler.ProcessRequest(HttpContext.Current);
     } finally {
         httpContext.Handler = origHttpHandler;
     }
 }
开发者ID:Mariamfelicia,项目名称:nreco,代码行数:13,代码来源:RoutingHttpHandler.cs

示例4: CaptureOutput

 public static string CaptureOutput(this HttpContext ctx, IHttpHandler page)
 {
     var old = ctx.Response.Output;
     try
     {
         var writer = new StringWriter();
         ctx.Response.Output = writer;
         page.ProcessRequest(ctx);
         return writer.ToString();
     }
     finally
     {
         ctx.Response.Output = old;
     }
 }
开发者ID:NielsKuhnel,项目名称:PageIslands,代码行数:15,代码来源:HttpResponseCaptureUtil.cs

示例5: ProcessRequest

        public static void ProcessRequest(this IHttpChannel channel, IHttpHandler handler, HttpServerSettings settings)
        {
            var context = new HttpContextImpl(channel, settings);
            var res = context.Response;

            using (res.OutputStream)
            {
                try
                {
                    var app = handler as ExpressApplication;
                    if (app != null)
                    {
                        if (!app.Process(context))
                        {
                            res.StatusCode = (int)HttpStatusCode.NotFound;
                            res.StatusDescription = "Not found";
                            res.ContentType = "text/plain";
                            res.Write("Resource not found!");
                        }

                        res.Flush();
                        res.End();
                    }
                    else
                    {
                        var workerRequest = new HttpWorkerRequestImpl(context, settings);
                        handler.ProcessRequest(new HttpContext(workerRequest));
                        workerRequest.EndOfRequest();
                    }
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(e);

                    res.StatusCode = (int)HttpStatusCode.InternalServerError;
                    res.ContentType = "text/plain";
                    res.Write(e.ToString());
                }
            }
        }
开发者ID:lstefano71,项目名称:SharpExpress,代码行数:40,代码来源:ProcessRequestExtension.cs

示例6: ExecuteInternal

 private void ExecuteInternal(IHttpHandler handler, TextWriter writer, bool preserveForm, bool setPreviousPage, VirtualPath path, VirtualPath filePath, string physPath, Exception error, string queryStringOverride)
 {
     if (handler == null)
     {
         throw new ArgumentNullException("handler");
     }
     HttpRequest request = this._context.Request;
     HttpResponse response = this._context.Response;
     HttpApplication applicationInstance = this._context.ApplicationInstance;
     HttpValueCollection form = null;
     VirtualPath path2 = null;
     string queryStringText = null;
     TextWriter writer2 = null;
     AspNetSynchronizationContext syncContext = null;
     this.VerifyTransactionFlow(handler);
     this._context.PushTraceContext();
     this._context.SetCurrentHandler(handler);
     bool enabled = this._context.SyncContext.Enabled;
     this._context.SyncContext.Disable();
     try
     {
         try
         {
             this._context.ServerExecuteDepth++;
             path2 = request.SwitchCurrentExecutionFilePath(filePath);
             if (!preserveForm)
             {
                 form = request.SwitchForm(new HttpValueCollection());
                 if (queryStringOverride == null)
                 {
                     queryStringOverride = string.Empty;
                 }
             }
             if (queryStringOverride != null)
             {
                 queryStringText = request.QueryStringText;
                 request.QueryStringText = queryStringOverride;
             }
             if (writer != null)
             {
                 writer2 = response.SwitchWriter(writer);
             }
             Page page = handler as Page;
             if (page != null)
             {
                 if (setPreviousPage)
                 {
                     page.SetPreviousPage(this._context.PreviousHandler as Page);
                 }
                 Page page2 = this._context.Handler as Page;
                 if ((page2 != null) && page2.SmartNavigation)
                 {
                     page.SmartNavigation = true;
                 }
                 if (page is IHttpAsyncHandler)
                 {
                     syncContext = this._context.InstallNewAspNetSynchronizationContext();
                 }
             }
             if (((handler is StaticFileHandler) || (handler is DefaultHttpHandler)) && !DefaultHttpHandler.IsClassicAspRequest(filePath.VirtualPathString))
             {
                 try
                 {
                     response.WriteFile(physPath);
                 }
                 catch
                 {
                     error = new HttpException(0x194, string.Empty);
                 }
             }
             else if (!(handler is Page))
             {
                 error = new HttpException(0x194, string.Empty);
             }
             else
             {
                 if (handler is IHttpAsyncHandler)
                 {
                     bool isInCancellablePeriod = this._context.IsInCancellablePeriod;
                     if (isInCancellablePeriod)
                     {
                         this._context.EndCancellablePeriod();
                     }
                     try
                     {
                         IHttpAsyncHandler handler2 = (IHttpAsyncHandler) handler;
                         IAsyncResult result = handler2.BeginProcessRequest(this._context, null, null);
                         if (!result.IsCompleted)
                         {
                             bool flag3 = false;
                             try
                             {
                                 try
                                 {
                                 }
                                 finally
                                 {
                                     Monitor.Exit(applicationInstance);
                                     flag3 = true;
                                 }
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:HttpServerUtility.cs

示例7: ProcessPage

		private void ProcessPage(IController controller, IHttpHandler page, HttpContext httpContext)
		{
			PreSendView(controller, page);

			page.ProcessRequest(httpContext);

			PostSendView(controller, page);
		}
开发者ID:ralescano,项目名称:castle,代码行数:8,代码来源:WebFormsViewEngine.cs

示例8: Execute

		internal void Execute (IHttpHandler handler, TextWriter writer, bool preserveForm, string exePath, string queryString, bool isTransfer, bool isInclude)
		{
			// 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");

			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 {
				context.PushHandler (handler);
				if (is_static) // Not sure if this should apply to Page too
					request.SetFilePath (exePath);

				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);

				context.PopHandler ();
				request.SetCurrentExePath (oldExePath);
				context.IsProcessingInclude = oldIsInclude;
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:65,代码来源:HttpServerUtility.cs

示例9: ExecuteInternal


//.........这里部分代码省略.........
                    if ((handler is StaticFileHandler || handler is DefaultHttpHandler) &&
                       !DefaultHttpHandler.IsClassicAspRequest(filePath.VirtualPathString)) {
                        // cannot apply static files handler directly
                        // -- it would dump the source of the current page
                        // instead just dump the file content into response
                        try {
                            response.WriteFile(physPath);
                        }
                        catch {
                            // hide the real error as it could be misleading
                            // in case of mismapped requests like /foo.asmx/bar
                            error = new HttpException(404, String.Empty);
                        }
                    }
                    else if (!(handler is Page)) {
                        // disallow anything but pages
                        error = new HttpException(404, String.Empty);
                    }
                    else if (handler is IHttpAsyncHandler) {
                        // Asynchronous handler

                        // suspend cancellable period (don't abort this thread while
                        // we wait for another to finish)
                        bool isCancellable =  _context.IsInCancellablePeriod;
                        if (isCancellable)
                            _context.EndCancellablePeriod();

                        try {
                            IHttpAsyncHandler asyncHandler = (IHttpAsyncHandler)handler;

                            if (!AppSettings.UseTaskFriendlySynchronizationContext) {
                                // Legacy code path: behavior ASP.NET <= 4.0

                                IAsyncResult ar = asyncHandler.BeginProcessRequest(_context, null, null);

                                // wait for completion
                                if (!ar.IsCompleted) {
                                    // suspend app lock while waiting
                                    bool needToRelock = false;

                                    try {
                                        try { }
                                        finally {
                                            _context.SyncContext.DisassociateFromCurrentThread();
                                            needToRelock = true;
                                        }

                                        WaitHandle h = ar.AsyncWaitHandle;

                                        if (h != null) {
                                            h.WaitOne();
                                        }
                                        else {
                                            while (!ar.IsCompleted)
                                                Thread.Sleep(1);
                                        }
                                    }
                                    finally {
                                        if (needToRelock) {
                                            _context.SyncContext.AssociateWithCurrentThread();
                                        }
                                    }
                                }

                                // end the async operation (get error if any)
开发者ID:uQr,项目名称:referencesource,代码行数:66,代码来源:httpserverutility.cs

示例10: ProcessRequest

 private static HttpResponse ProcessRequest(IHttpHandler page, TextWriter writer)
 {
     var response = new HttpResponse(writer);
     var context = new HttpContext(HttpContext.Current.Request, response);
     context.SetSessionStateBehavior(SessionStateBehavior.Required);
     page.ProcessRequest(context);
     return response;
 }
开发者ID:malteclasen,项目名称:MvcMigration,代码行数:8,代码来源:WebFormsHelper.cs

示例11: ShowDebugInfo

		private void ShowDebugInfo(HttpContext context, IHttpHandler handler)
		{
			if( s_IntegratedPipeline == false ) {
				handler.ProcessRequest(context);
			}
			else {
				bool isAfterMapRequestHandler = false;
				try {
					context.RemapHandler(handler);
				}
				catch( InvalidOperationException ) {
					// 在IIS7的集成管线模式下,当前阶段 >= MapRequestHandler 时,会引发这个异常
					isAfterMapRequestHandler = true;
				}

				if( isAfterMapRequestHandler )
					handler.ProcessRequest(context);
			}
						

		}
开发者ID:ChinaSuperLiu,项目名称:ClownFish.Mvc,代码行数:21,代码来源:Http404DebugModule.cs

示例12: MoveNext


//.........这里部分代码省略.........
yield_13:
				if (_this.PostAcquireRequestState != null){
					//foreach (bool stop in RunHooks (PostAcquireRequestState))
					//	yield return stop;
					if (currentEnumerator == null) {
						currentYield = 13;
						currentEnumerator = _this.RunHooks(_this.PostAcquireRequestState).GetEnumerator();
					}
					while (currentEnumerator.MoveNext())
						return true;

					ResetEnumerator();
				}
#endif
			
				//
				// From this point on, we need to ensure that we call
				// ReleaseRequestState, so the code below jumps to
				// `release:' to guarantee it rather than yielding.
				//
				if (_this.PreRequestHandlerExecute != null)
					foreach (bool stop in _this.RunHooks (_this.PreRequestHandlerExecute))
						if (stop)
							goto release;
				
				try {
					_this.context.BeginTimeoutPossible ();
					if (handler != null){
						IHttpAsyncHandler async_handler = handler as IHttpAsyncHandler;
					
						if (async_handler != null){
							_this.must_yield = true;
							_this.in_begin = true;
							async_handler.BeginProcessRequest (_this.context, new AsyncCallback(_this.async_handler_complete_cb), handler);
						} else {
							_this.must_yield = false;
							handler.ProcessRequest (_this.context);
						}
					}
				} catch (ThreadAbortException taex){
					object obj = taex.ExceptionState;
					Thread.ResetAbort ();
					_this.stop_processing = true;
					if (obj is StepTimeout)
						_this.ProcessError (new HttpException ("The request timed out."));
				} catch (Exception e){
					_this.ProcessError (e);
				} finally {
					_this.in_begin = false;
					_this.context.EndTimeoutPossible ();
				}
				if (_this.must_yield) {
					//yield return stop_processing;
					current = _this.stop_processing;
					currentYield = 14;
					return true;
				}
				else if (_this.stop_processing)
					goto release;
yield_14:	
				// These are executed after the application has returned
			
				if (_this.PostRequestHandlerExecute != null)
					foreach (bool stop in _this.RunHooks (_this.PostRequestHandlerExecute))
						if (stop)
							goto release;
开发者ID:carrie901,项目名称:mono,代码行数:67,代码来源:HttpApplication.jvm.cs


注:本文中的IHttpHandler.ProcessRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。