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


C# HttpContextBase.EndHttpHandlerRequest方法代码示例

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


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

示例1: ProcessRequest

        /// <summary>
        /// ASP.NET requests
        /// </summary>
        public override void ProcessRequest(HttpContextBase context)
        {
            var defaultUrl = HostContext.Config.ServiceEndpointsMetadataConfig.DefaultMetadataUri;

            if (context.Request.PathInfo == "/"
                || context.Request.FilePath.EndsWith("/"))
            {
                //new NotFoundHttpHandler().ProcessRequest(context); return;

                var relativeUrl = defaultUrl.Substring(defaultUrl.IndexOf('/'));
                var absoluteUrl = context.Request.Url.AbsoluteUri.TrimEnd('/') + relativeUrl;
                context.Response.Redirect(absoluteUrl);
            }
            else
            {
                context.Response.Redirect(defaultUrl);
            }
            context.EndHttpHandlerRequest(skipHeaders: true);
        }
开发者ID:CLupica,项目名称:ServiceStack,代码行数:22,代码来源:IndexPageHttpHandler.cs

示例2: ProcessRequest

        /// <summary>
        /// ASP.NET requests
        /// </summary>
        /// <param name="context"></param>
        public override void ProcessRequest(HttpContextBase context)
        {
            var request = context.Request;
            var response = context.Response;

            if (string.IsNullOrEmpty(RelativeUrl) && string.IsNullOrEmpty(AbsoluteUrl))
                throw new ArgumentException("RelativeUrl and AbsoluteUrl is Required");

            if (!string.IsNullOrEmpty(AbsoluteUrl))
            {
                response.StatusCode = (int)StatusCode;
                response.AddHeader(HttpHeaders.Location, this.AbsoluteUrl);
            }
            else
            {
                var absoluteUrl = request.GetApplicationUrl();
                if (!string.IsNullOrEmpty(RelativeUrl))
                {
                    if (this.RelativeUrl.StartsWith("/"))
                        absoluteUrl = absoluteUrl.CombineWith(this.RelativeUrl);
                    else if (this.RelativeUrl.StartsWith("~/"))
                        absoluteUrl = absoluteUrl.CombineWith(this.RelativeUrl.Replace("~/", ""));
                    else
                        absoluteUrl = request.Url.AbsoluteUri.CombineWith(this.RelativeUrl);
                }
                response.StatusCode = (int)StatusCode;
                response.AddHeader(HttpHeaders.Location, absoluteUrl);
            }

            context.EndHttpHandlerRequest(closeOutputStream: true);
        }
开发者ID:ServiceStack,项目名称:ServiceStack,代码行数:35,代码来源:RedirectHttpHandler.cs

示例3: ProcessRequest

        public override void ProcessRequest(HttpContextBase context)
        {
            var request = context.Request;
            var response = context.Response;

            response.ContentType = "text/plain";
            response.StatusCode = 403;

            context.EndHttpHandlerRequest(skipClose: true, afterHeaders: r =>
            {
                r.Write("Forbidden\n\n");

                r.Write("\nRequest.HttpMethod: " + request.HttpMethod);
                r.Write("\nRequest.PathInfo: " + request.PathInfo);
                r.Write("\nRequest.QueryString: " + request.QueryString);

                if (HostContext.Config.DebugMode)
                {
                    r.Write("\nRequest.RawUrl: " + request.RawUrl);

                    if (IsIntegratedPipeline.HasValue)
                        r.Write("\nApp.IsIntegratedPipeline: " + IsIntegratedPipeline);
                    if (!WebHostPhysicalPath.IsNullOrEmpty())
                        r.Write("\nApp.WebHostPhysicalPath: " + WebHostPhysicalPath);
                    if (!WebHostRootFileNames.IsEmpty())
                        r.Write("\nApp.WebHostRootFileNames: " + TypeSerializer.SerializeToString(WebHostRootFileNames));
                    if (!WebHostUrl.IsNullOrEmpty())
                        r.Write("\nApp.ApplicationBaseUrl: " + WebHostUrl);
                    if (!DefaultRootFileName.IsNullOrEmpty())
                        r.Write("\nApp.DefaultRootFileName: " + DefaultRootFileName);
                }
            });
        }
开发者ID:CLupica,项目名称:ServiceStack,代码行数:33,代码来源:ForbiddenHttpHandler.cs

示例4: ProcessRequest

        public override void ProcessRequest(HttpContextBase context)
        {
            var request = context.Request;
            var response = context.Response;

            var httpReq = context.ToRequest(GetType().GetOperationName());
            if (!request.IsLocal)
            {
                ProcessRequestAsync(httpReq, httpReq.Response, null);
                return;
            }

            Log.ErrorFormat("{0} Request not found: {1}", request.UserHostAddress, request.RawUrl);

            var sb = new StringBuilder();
            sb.AppendLine("Handler for Request not found: \n\n");

            sb.AppendLine("Request.ApplicationPath: " + request.ApplicationPath);
            sb.AppendLine("Request.CurrentExecutionFilePath: " + request.CurrentExecutionFilePath);
            sb.AppendLine("Request.FilePath: " + request.FilePath);
            sb.AppendLine("Request.HttpMethod: " + request.HttpMethod);
            sb.AppendLine("Request.MapPath('~'): " + request.MapPath("~"));
            sb.AppendLine("Request.Path: " + request.Path);
            sb.AppendLine("Request.PathInfo: " + request.PathInfo);
            sb.AppendLine("Request.ResolvedPathInfo: " + httpReq.PathInfo);
            sb.AppendLine("Request.PhysicalPath: " + request.PhysicalPath);
            sb.AppendLine("Request.PhysicalApplicationPath: " + request.PhysicalApplicationPath);
            sb.AppendLine("Request.QueryString: " + request.QueryString);
            sb.AppendLine("Request.RawUrl: " + request.RawUrl);
            try
            {
                sb.AppendLine("Request.Url.AbsoluteUri: " + request.Url.AbsoluteUri);
                sb.AppendLine("Request.Url.AbsolutePath: " + request.Url.AbsolutePath);
                sb.AppendLine("Request.Url.Fragment: " + request.Url.Fragment);
                sb.AppendLine("Request.Url.Host: " + request.Url.Host);
                sb.AppendLine("Request.Url.LocalPath: " + request.Url.LocalPath);
                sb.AppendLine("Request.Url.Port: " + request.Url.Port);
                sb.AppendLine("Request.Url.Query: " + request.Url.Query);
                sb.AppendLine("Request.Url.Scheme: " + request.Url.Scheme);
                sb.AppendLine("Request.Url.Segments: " + request.Url.Segments);
            }
            catch (Exception ex)
            {
                sb.AppendLine("Request.Url ERROR: " + ex.Message);
            }
            if (IsIntegratedPipeline.HasValue)
                sb.AppendLine("App.IsIntegratedPipeline: " + IsIntegratedPipeline);
            if (!WebHostPhysicalPath.IsNullOrEmpty())
                sb.AppendLine("App.WebHostPhysicalPath: " + WebHostPhysicalPath);
            if (!WebHostRootFileNames.IsEmpty())
                sb.AppendLine("App.WebHostRootFileNames: " + TypeSerializer.SerializeToString(WebHostRootFileNames));
            if (!WebHostUrl.IsNullOrEmpty())
                sb.AppendLine("App.ApplicationBaseUrl: " + WebHostUrl);
            if (!DefaultRootFileName.IsNullOrEmpty())
                sb.AppendLine("App.DefaultRootFileName: " + DefaultRootFileName);
            if (!DefaultHandler.IsNullOrEmpty())
                sb.AppendLine("App.DefaultHandler: " + DefaultHandler);
            if (!HttpHandlerFactory.DebugLastHandlerArgs.IsNullOrEmpty())
                sb.AppendLine("App.DebugLastHandlerArgs: " + HttpHandlerFactory.DebugLastHandlerArgs);

            response.ContentType = "text/plain";
            response.StatusCode = 404;
            context.EndHttpHandlerRequest(skipClose: true, afterHeaders: r => r.Write(sb.ToString()));
        }
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:64,代码来源:NotFoundHttpHandler.cs


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