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


C# IResponse.EndHttpHandlerRequest方法代码示例

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


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

示例1: ProcessRequest

        public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
        {
            HostContext.ApplyCustomHandlerRequestFilters(httpReq, httpRes);
            if (httpRes.IsClosed) return;

            httpRes.ContentType = MimeTypes.Html;
            if (RazorFormat == null)
                RazorFormat = RazorFormat.Instance;

            var contentPage = RazorPage ?? RazorFormat.GetContentPage(PathInfo);
            if (contentPage == null)
            {
                httpRes.StatusCode = (int)HttpStatusCode.NotFound;
                httpRes.EndHttpHandlerRequest();
                return;
            }

            var model = Model;
            if (model == null)
                httpReq.Items.TryGetValue("Model", out model);
            if (model == null)
            {
                var modelType = RazorPage?.ModelType;
                model = modelType == null || modelType == typeof(DynamicRequestObject)
                    ? null
                    : DeserializeHttpRequest(modelType, httpReq, httpReq.ContentType);
            }

            RazorFormat.ProcessRazorPage(httpReq, contentPage, model, httpRes);
            httpRes.EndHttpHandlerRequest(skipHeaders:true);
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:31,代码来源:RazorHandler.cs

示例2: ProcessRequest

        public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
        {
            HostContext.ApplyCustomHandlerRequestFilters(httpReq, httpRes);
            if (httpRes.IsClosed) return;

            if (MarkdownFormat == null)
                MarkdownFormat = MarkdownFormat.Instance;

            var contentPage = MarkdownPage ?? MarkdownFormat.FindByPathInfo(PathInfo);
            if (contentPage == null)
            {
                httpRes.StatusCode = (int)HttpStatusCode.NotFound;
                httpRes.EndHttpHandlerRequest();
                return;
            }

            MarkdownFormat.ReloadModifiedPageAndTemplates(contentPage);

            if (httpReq.DidReturn304NotModified(contentPage.GetLastModified(), httpRes))
                return;

            var model = Model;
            if (model == null)
                httpReq.Items.TryGetValue("Model", out model);

            MarkdownFormat.ProcessMarkdownPage(httpReq, contentPage, model, httpRes);
        }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:27,代码来源:MarkdownHandler.cs

示例3: ProcessRequest

        public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
        {
            httpRes.ContentType = MimeTypes.Html;
            if (RazorFormat == null)
                RazorFormat = RazorFormat.Instance;

            var contentPage = RazorPage ?? RazorFormat.FindByPathInfo(PathInfo);
            if (contentPage == null)
            {
                httpRes.StatusCode = (int)HttpStatusCode.NotFound;
                httpRes.EndHttpHandlerRequest();
                return;
            }

            var model = Model;
            if (model == null)
                httpReq.Items.TryGetValue("Model", out model);
            if (model == null)
            {
                var modelType = RazorPage != null ? RazorPage.ModelType : null;
                model = modelType == null || modelType == typeof(DynamicRequestObject)
                    ? null
                    : DeserializeHttpRequest(modelType, httpReq, httpReq.ContentType);
            }

            RazorFormat.ProcessRazorPage(httpReq, contentPage, model, httpRes);
        }
开发者ID:nustack,项目名称:ServiceStack,代码行数:27,代码来源:RazorHandler.cs

示例4: ProcessRequest

        public override void ProcessRequest(IRequest request, IResponse response, string operationName)
        {
            response.ContentType = "text/plain";
            response.StatusCode = 403;

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

                r.Write("\nRequest.HttpMethod: " + request.Verb);
                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.WebHostUrl: " + WebHostUrl);
                    if (!DefaultRootFileName.IsNullOrEmpty())
                        r.Write("\nApp.DefaultRootFileName: " + DefaultRootFileName);
                    if (!DefaultHandler.IsNullOrEmpty())
                        r.Write("\nApp.DefaultHandler: " + DefaultHandler);
                    if (!HttpHandlerFactory.DebugLastHandlerArgs.IsNullOrEmpty())
                        r.Write("\nApp.DebugLastHandlerArgs: " + HttpHandlerFactory.DebugLastHandlerArgs);
                }
            });
		}
开发者ID:tystol,项目名称:ServiceStack,代码行数:33,代码来源:ForbiddenHttpHandler.cs

示例5: ProcessRequest

        /// <summary>
        /// Non ASP.NET requests
        /// </summary>
        /// <param name="request"></param>
        /// <param name="response"></param>
        /// <param name="operationName"></param>
        public override void ProcessRequest(IRequest request, IResponse response, string operationName)
        {
            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.AbsoluteUri.CombineWith(this.RelativeUrl);
                }
                response.StatusCode = (int)StatusCode;
                response.AddHeader(HttpHeaders.Location, absoluteUrl);
            }

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

示例6: ProcessRequest

        public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
        {
            if (HostContext.ApplyCustomHandlerRequestFilters(httpReq, httpRes))
                return;

            Action(httpReq, httpRes);
            httpRes.EndHttpHandlerRequest(skipHeaders:true);
        }
开发者ID:CLupica,项目名称:ServiceStack,代码行数:8,代码来源:CustomActionHandler.cs

示例7: ProcessRequest

        public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
        {
            if (HostContext.ApplyCustomHandlerRequestFilters(httpReq, httpRes))
                return;

            using (var sw = new StreamWriter(httpRes.OutputStream))
            {
                var writer = new HtmlTextWriter(sw);
               httpRes.ContentType = "text/html; charset=utf-8";
               ProcessOperations(writer, httpReq, httpRes);
            }

            httpRes.EndHttpHandlerRequest(skipHeaders:true);
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:14,代码来源:BaseMetadataHandler.cs

示例8: ProcessRequest

        public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
        {
            if (HostContext.ApplyCustomHandlerRequestFilters(httpReq, httpRes))
                return;
            if (textContents == null && bytes == null)
                return;

            httpRes.ContentType = contentType;

            if (textContents != null)
                httpRes.Write(textContents);
            else if (bytes != null)
                httpRes.OutputStream.Write(bytes, 0, bytes.Length);

            httpRes.Flush();
            httpRes.EndHttpHandlerRequest(skipHeaders: true);
        }
开发者ID:CLupica,项目名称:ServiceStack,代码行数:17,代码来源:StaticContentHandler.cs

示例9: ProcessRequest

        /// <summary>
        /// Non ASP.NET requests
        /// </summary>
        public override void ProcessRequest(IRequest request, IResponse response, string operationName)
        {
            var defaultUrl = HostContext.Config.ServiceEndpointsMetadataConfig.DefaultMetadataUri;

            if (request.PathInfo == "/")
            {
                var relativeUrl = defaultUrl.Substring(defaultUrl.IndexOf('/'));
                var absoluteUrl = request.RawUrl.TrimEnd('/') + relativeUrl;
                response.StatusCode = (int)HttpStatusCode.Redirect;
                response.AddHeader(HttpHeaders.Location, absoluteUrl);
            }
            else
            {
                response.StatusCode = (int)HttpStatusCode.Redirect;
                response.AddHeader(HttpHeaders.Location, defaultUrl);
            }
            response.EndHttpHandlerRequest(skipHeaders:true);
        }
开发者ID:CLupica,项目名称:ServiceStack,代码行数:21,代码来源:IndexPageHttpHandler.cs

示例10: ProcessRequest

        public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
        {
            if (HostContext.ApplyCustomHandlerRequestFilters(httpReq, httpRes))
                return;

            if (!AssertAccess(httpReq, httpRes, httpReq.QueryString["op"])) return;

            var operationTypes = HostContext.Metadata.GetAllSoapOperationTypes();

            if (httpReq.QueryString["xsd"] != null)
            {
#if !NETSTANDARD1_6
                var xsdNo = Convert.ToInt32(httpReq.QueryString["xsd"]);
                var schemaSet = XsdUtils.GetXmlSchemaSet(operationTypes);
                var schemas = schemaSet.Schemas();
                var i = 0;
                if (xsdNo >= schemas.Count)
                    throw new ArgumentOutOfRangeException("xsd");

                httpRes.ContentType = "text/xml";
                foreach (XmlSchema schema in schemaSet.Schemas())
                {
                    if (xsdNo != i++) continue;
                    schema.Write(httpRes.OutputStream);
                    break;
                }
#endif
            }
            else
            {
                using (var sw = new StreamWriter(httpRes.OutputStream))
                {
                    var writer = new HtmlTextWriter(sw);
                    httpRes.ContentType = "text/html; charset=utf-8";
                    ProcessOperations(writer, httpReq, httpRes);
                }
            }

            httpRes.EndHttpHandlerRequest(skipHeaders:true);
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:40,代码来源:BaseSoapMetadataHandler.cs

示例11: ProcessRequest

        public override void ProcessRequest(IRequest request, IResponse response, string operationName)
        {
            HostContext.AppHost.OnLogError(typeof(NotFoundHttpHandler),
                $"{request.UserHostAddress} Request not found: {request.RawUrl}");

            var sb = StringBuilderCache.Allocate();

            var responseStatus = response.Dto.GetResponseStatus();
            if (responseStatus != null)
            {
                sb.AppendLine(
                    responseStatus.ErrorCode != responseStatus.Message
                    ? $"Error ({responseStatus.ErrorCode}): {responseStatus.Message}\n"
                    : $"Error: {responseStatus.Message ?? responseStatus.ErrorCode}\n");
            }

            if (HostContext.DebugMode)
            {
                sb.AppendLine("Handler for Request not found (404):\n")
                    .AppendLine("  Request.HttpMethod: " + request.Verb)
                    .AppendLine("  Request.PathInfo: " + request.PathInfo)
                    .AppendLine("  Request.QueryString: " + request.QueryString)
                    .AppendLine("  Request.RawUrl: " + request.RawUrl);
            }
            else
            {
                sb.Append("404");
            }

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

            if (responseStatus != null)
                response.StatusDescription = responseStatus.ErrorCode;

            var text = StringBuilderCache.ReturnAndFree(sb);
            response.EndHttpHandlerRequest(skipClose: true, afterHeaders: r => r.Write(text));
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:38,代码来源:NotFoundHttpHandler.cs

示例12: ProcessRequest

		public override void ProcessRequest(IRequest request, IResponse response, string operationName)
		{
            Log.ErrorFormat("{0} Request not found: {1}", request.UserHostAddress, request.RawUrl);

		    var text = new StringBuilder();

            if (HostContext.DebugMode)
            {
                text.AppendLine("Handler for Request not found: \n\n")
                    .AppendLine("Request.HttpMethod: " + request.Verb)
                    .AppendLine("Request.PathInfo: " + request.PathInfo)
                    .AppendLine("Request.QueryString: " + request.QueryString)
                    .AppendLine("Request.RawUrl: " + request.RawUrl);
            }
            else
            {
                text.Append("404");
            }

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

示例13: ProcessRequest

        public override void ProcessRequest(IRequest request, IResponse response, string operationName)
        {
            Log.ErrorFormat("{0} Request not found: {1}", request.UserHostAddress, request.RawUrl);

            var text = new StringBuilder();

            var responseStatus = response.Dto.GetResponseStatus();
            if (responseStatus != null)
            {
                text.AppendLine(
                    responseStatus.ErrorCode != responseStatus.Message
                    ? "Error ({0}): {1}\n".Fmt(responseStatus.ErrorCode, responseStatus.Message)
                    : "Error: {0}\n".Fmt(responseStatus.Message ?? responseStatus.ErrorCode));
            }

            if (HostContext.DebugMode)
            {
                text.AppendLine("Handler for Request not found (404):\n")
                    .AppendLine("  Request.HttpMethod: " + request.Verb)
                    .AppendLine("  Request.PathInfo: " + request.PathInfo)
                    .AppendLine("  Request.QueryString: " + request.QueryString)
                    .AppendLine("  Request.RawUrl: " + request.RawUrl);
            }
            else
            {
                text.Append("404");
            }

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

            if (responseStatus != null)
                response.StatusDescription = responseStatus.ErrorCode;

            response.EndHttpHandlerRequest(skipClose: true, afterHeaders: r => r.Write(text.ToString()));
        }
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:36,代码来源:NotFoundHttpHandler.cs

示例14: ProcessRequest

        public override void ProcessRequest(IRequest request, IResponse response, string operationName)
        {
            HostContext.ApplyCustomHandlerRequestFilters(request, response);
            if (response.IsClosed) return;

            response.EndHttpHandlerRequest(skipClose: true, afterHeaders: r =>
            {
                var node = this.VirtualNode ?? request.GetVirtualNode();
                var file = node as IVirtualFile;
                if (file == null)
                {
                    var dir = node as IVirtualDirectory;
                    if (dir != null)
                    {
                        file = dir.GetDefaultDocument();
                        if (file != null && HostContext.Config.RedirectToDefaultDocuments)
                        {
                            r.Redirect(request.GetPathUrl() + '/' + file.Name);
                            return;
                        }
                    }

                    if (file == null)
                    {
                        var fileName = request.PathInfo;
                        var originalFileName = fileName;

                        if (Env.IsMono)
                        {
                            //Create a case-insensitive file index of all host files
                            if (allFiles == null)
                                allFiles = CreateFileIndex(HostContext.VirtualPathProvider.RootDirectory.RealPath);
                            if (allDirs == null)
                                allDirs = CreateDirIndex(HostContext.VirtualPathProvider.RootDirectory.RealPath);

                            if (allFiles.TryGetValue(fileName.ToLower(), out fileName))
                            {
                                file = HostContext.VirtualPathProvider.GetFile(fileName);
                            }
                        }

                        if (file == null)
                        {
                            var msg = ErrorMessages.FileNotExistsFmt.Fmt(request.PathInfo);
                            log.WarnFormat("{0} in path: {1}", msg, originalFileName);
                            response.StatusCode = 404;
                            response.StatusDescription = msg;
                            return;
                        }
                    }
                }

                file.Refresh(); //refresh FileInfo, DateModified, Length

                TimeSpan maxAge;
                if (r.ContentType != null && HostContext.Config.AddMaxAgeForStaticMimeTypes.TryGetValue(r.ContentType, out maxAge))
                {
                    r.AddHeader(HttpHeaders.CacheControl, "max-age=" + maxAge.TotalSeconds);
                }

                if (request.HasNotModifiedSince(file.LastModified))
                {
                    r.ContentType = MimeTypes.GetMimeType(file.Name);
                    r.StatusCode = 304;
                    return;
                }

                try
                {
                    r.AddHeaderLastModified(file.LastModified);
                    r.ContentType = MimeTypes.GetMimeType(file.Name);

                    if (ResponseFilter != null)
                    {
                        ResponseFilter(request, r, file);

                        if (r.IsClosed)
                            return;
                    }

                    if (file.VirtualPath.EqualsIgnoreCase(DefaultFilePath))
                    {
                        if (file.LastModified > DefaultFileModified)
                            SetDefaultFile(DefaultFilePath, file.ReadAllBytes(), file.LastModified); //reload

                        r.OutputStream.Write(DefaultFileContents, 0, DefaultFileContents.Length);
                        r.Close();
                        return;
                    }

                    if (HostContext.Config.AllowPartialResponses)
                        r.AddHeader(HttpHeaders.AcceptRanges, "bytes");
                    long contentLength = file.Length;
                    long rangeStart, rangeEnd;
                    var rangeHeader = request.Headers[HttpHeaders.Range];
                    if (HostContext.Config.AllowPartialResponses && rangeHeader != null)
                    {
                        rangeHeader.ExtractHttpRanges(contentLength, out rangeStart, out rangeEnd);

                        if (rangeEnd > contentLength - 1)
//.........这里部分代码省略.........
开发者ID:jrmitch120,项目名称:ServiceStack,代码行数:101,代码来源:StaticFileHandler.cs

示例15: ProcessRequestAsync

 public override Task ProcessRequestAsync(IRequest req, IResponse res, string operationName)
 {
     //req.TryResolve<IMyServerEvents>().Pulse(req.QueryString["id"]);
     res.EndHttpHandlerRequest(skipHeaders: true);
     return ((object)null).AsTaskResult();
 }
开发者ID:jklemmack,项目名称:ServerSentEvents4ServiceStack,代码行数:6,代码来源:SimpleServerEventsFeature.cs


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