本文整理汇总了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();
}
示例2: WriteDebugResponse
public static void WriteDebugResponse(IHttpResponse httpRes, object response)
{
httpRes.WriteToResponse(response, WriteDebugRequest,
new SerializationContext(ContentType.PlainText));
httpRes.ApplyGlobalResponseHeaders();
httpRes.Close();
}
示例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();
}
示例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();
}
示例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();
}