本文整理汇总了C#中System.Web.HttpResponseBase.isNull方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponseBase.isNull方法的具体用法?C# HttpResponseBase.isNull怎么用?C# HttpResponseBase.isNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpResponseBase
的用法示例。
在下文中一共展示了HttpResponseBase.isNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setGZipCompression_forAjaxRequests
public static bool setGZipCompression_forAjaxRequests(HttpRequestBase request, HttpResponseBase response)
{
if (request.isNull() || response.isNull())
return false;
//based on code from http://geekswithblogs.net/rashid/archive/2007/09/15/Compress-Asp.net-Ajax-Web-Service-Response---Save-Bandwidth.aspx
if (TMConfig.Current.enableGZipForWebServices().isFalse())
return false;
if (request.Url.isNull() || request.Url.AbsolutePath.starts("/rest")) //disabled it for rest requests
return false;
try
{
if (request.ContentType.lower().starts(new List<string> {"text/xml", "application/json"}))
{
string acceptEncoding = request.Headers["Accept-Encoding"];
if (!string.IsNullOrEmpty(acceptEncoding))
{
acceptEncoding = acceptEncoding.ToLower(CultureInfo.InvariantCulture);
if (acceptEncoding.Contains("gzip"))
{
response.Filter = new GZipStream(response.Filter, CompressionMode.Compress);
response.AddHeader("Content-encoding", "gzip");
return true;
}
if (acceptEncoding.Contains("deflate"))
{
response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress);
response.AddHeader("Content-encoding", "deflate");
return true;
}
}
}
}
catch (Exception ex)
{
ex.log("in enableGZipCompression_forAjaxRequests");
}
return false;
}