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


C# IHttpResponse.ApplyGlobalResponseHeaders方法代码示例

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


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

示例1: ProcessRequest

        public void ProcessRequest(IHttpRequest request, IHttpResponse response, string operationName)
        {
            response.ContentType = "text/plain";
            response.StatusCode = 403;
            response.Write("Forbidden\n\n");

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

            if (IsIntegratedPipeline.HasValue)
                response.Write("\nApp.IsIntegratedPipeline: " + IsIntegratedPipeline);
            if (!WebHostPhysicalPath.IsNullOrEmpty())
                response.Write("\nApp.WebHostPhysicalPath: " + WebHostPhysicalPath);
            if (!WebHostRootFileNames.IsEmpty())
                response.Write("\nApp.WebHostRootFileNames: " + TypeSerializer.SerializeToString(WebHostRootFileNames));
            if (!ApplicationBaseUrl.IsNullOrEmpty())
                response.Write("\nApp.ApplicationBaseUrl: " + ApplicationBaseUrl);
            if (!DefaultRootFileName.IsNullOrEmpty())
                response.Write("\nApp.DefaultRootFileName: " + DefaultRootFileName);
            if (!DefaultHandler.IsNullOrEmpty())
                response.Write("\nApp.DefaultHandler: " + DefaultHandler);
            if (!ServiceStackHttpHandlerFactory.DebugLastHandlerArgs.IsNullOrEmpty())
                response.Write("\nApp.DebugLastHandlerArgs: " + ServiceStackHttpHandlerFactory.DebugLastHandlerArgs);

            response.ApplyGlobalResponseHeaders();
            //Apache+mod_mono doesn't like this
            //response.OutputStream.Flush();
            //response.Close();
        }
开发者ID:kevingessner,项目名称:ServiceStack,代码行数:31,代码来源:ForbiddenHttpHandler.cs

示例2: WriteDebugResponse

        public static void WriteDebugResponse(IHttpResponse httpRes, object response)
        {
            httpRes.WriteToResponse(response, WriteDebugRequest,
                new SerializationContext(ContentType.PlainText));

            httpRes.ApplyGlobalResponseHeaders();
            httpRes.Close();
        }
开发者ID:kevingessner,项目名称:ServiceStack,代码行数:8,代码来源:JsvSyncReplyHandler.cs

示例3: ProcessRequest

        /// <summary>
        /// Non ASP.NET requests
        /// </summary>
        /// <param name="request"></param>
        /// <param name="response"></param>
        /// <param name="operationName"></param>
        public void ProcessRequest(IHttpRequest request, IHttpResponse response, string operationName)
        {
            if (string.IsNullOrEmpty(RelativeUrl) && string.IsNullOrEmpty(AbsoluteUrl))
                throw new ArgumentNullException("RelativeUrl or AbsoluteUrl");

            if (!string.IsNullOrEmpty(AbsoluteUrl))
            {
                response.StatusCode = (int)HttpStatusCode.Redirect;
                response.AddHeader(HttpHeaders.Location, this.AbsoluteUrl);
            }
            else
            {
                var absoluteUrl = request.AbsoluteUri.WithTrailingSlash() + this.RelativeUrl;
                response.StatusCode = (int)HttpStatusCode.Redirect;
                response.AddHeader(HttpHeaders.Location, absoluteUrl);
            }

            response.ApplyGlobalResponseHeaders();

            response.Close();
        }
开发者ID:kevingessner,项目名称:ServiceStack,代码行数:27,代码来源:RedirectHttpHandler.cs

示例4: HandleFailedAuth

        public static void HandleFailedAuth(IAuthProvider authProvider,
            IAuthSession session, IHttpRequest httpReq, IHttpResponse httpRes)
        {
            var baseAuthProvider = authProvider as AuthProvider;
            if (baseAuthProvider != null)
            {
                baseAuthProvider.OnFailedAuthentication(session, httpReq, httpRes);
                return;
            }

            httpRes.StatusCode = (int)HttpStatusCode.Unauthorized;
            httpRes.AddHeader(HttpHeaders.WwwAuthenticate, "{0} realm=\"{1}\""
                .Fmt(authProvider.Provider, authProvider.AuthRealm));

            httpRes.ApplyGlobalResponseHeaders();
            httpRes.Close();
        }
开发者ID:kevingessner,项目名称:ServiceStack,代码行数:17,代码来源:AuthProvider.cs

示例5: OnFailedAuthentication

 public virtual void OnFailedAuthentication(IAuthSession session, IHttpRequest httpReq, IHttpResponse httpRes)
 {
     httpRes.StatusCode = (int)HttpStatusCode.Unauthorized;
     httpRes.AddHeader(HttpHeaders.WwwAuthenticate, "{0} realm=\"{1}\"".Fmt(this.Provider, this.AuthRealm));
     httpRes.ApplyGlobalResponseHeaders();
     httpRes.Close();
 }
开发者ID:kevingessner,项目名称:ServiceStack,代码行数:7,代码来源:AuthProvider.cs


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