本文整理汇总了C#中System.Web.HttpResponse.AppendHeader方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponse.AppendHeader方法的具体用法?C# HttpResponse.AppendHeader怎么用?C# HttpResponse.AppendHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpResponse
的用法示例。
在下文中一共展示了HttpResponse.AppendHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
public void Process(HttpResponse response)
{
response.AppendHeader("Last-Modified", serverFingerprint.LastModifiedTime.ToString("r"));
response.AppendHeader("ETag", serverFingerprint.ETag);
response.AppendHeader("Cache-Control", "private, max-age=0");
if (!string.IsNullOrEmpty(fileName))
{
response.AppendHeader(
"Content-Disposition",
"attachment; filename=\"" + Path.GetFileName(fileName) + "\"");
}
if (!string.IsNullOrEmpty(type))
{
response.ContentType = type;
}
else if (!string.IsNullOrEmpty(fileName))
{
var mimeType = GetMimeType(fileName);
response.ContentType = mimeType;
}
else
{
response.ContentType = "application/octetstream";
}
fileTransfer.Download(response.OutputStream);
}
示例2: AddCompressionFilter
public static void AddCompressionFilter(HttpRequest request, HttpResponse response)
{
// load encodings from header
QValueList encodings = new QValueList(request.Headers["Accept-Encoding"]);
// get the types we can handle, can be accepted and
// in the defined client preference
QValue preferred = encodings.FindPreferred("gzip", "deflate", "identity");
// if none of the preferred values were found, but the
// client can accept wildcard encodings, we'll default
// to Gzip.
if (preferred.IsEmpty && encodings.AcceptWildcard && encodings.Find("gzip").IsEmpty)
preferred = new QValue("gzip");
// handle the preferred encoding
switch (preferred.Name)
{
case "gzip":
response.AppendHeader("Content-Encoding", "gzip");
response.Filter = new GZipStream(response.Filter, CompressionMode.Compress);
break;
case "deflate":
response.AppendHeader("Content-Encoding", "deflate");
response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress);
break;
case "identity":
default:
break;
}
}
示例3: Process
public void Process(HttpResponse response)
{
response.AppendHeader("Last-Modified", serverFingerprint.LastModifiedTime.ToString("r"));
response.AppendHeader("ETag", serverFingerprint.ETag);
response.AppendHeader("Cache-Control", "private, max-age=0");
response.BinaryWrite(content);
}
示例4: Process
public void Process(HttpResponse response)
{
response.AppendHeader("Last-Modified", serverFingerprint.LastModifiedTime.ToString("r"));
response.AppendHeader("ETag", serverFingerprint.ETag);
response.AppendHeader("Cache-Control", "private, max-age=0");
response.ContentType = MimeType.Json.ContentType;
response.Write(jsonFragment);
}
示例5: ToExcel
public static void ToExcel(DataSet dsInput, string filename, HttpResponse response)
{
var excelXml = GetExcelXml(dsInput, filename);
response.Clear();
response.AppendHeader("Content-Type", "application/vnd.ms-excel");
response.AppendHeader("Content-Disposition", "attachment; filename=\"" + HttpContext.Current.Server.UrlEncode(filename) + "\"");
response.Write(excelXml);
response.Flush();
response.End();
}
示例6: ProcessRequest
/// <summary>
/// ����IHttpHandler����
/// </summary>
/// <param name="context"></param>
public void ProcessRequest(HttpContext context)
{
Request = context.Request;
Response = context.Response;
Session = context.Session;
VerifyImage dt_verifyImage = new VerifyImage();
dt_verifyImage._Random = new Random();
dt_verifyImage._Code = dt_verifyImage.GetRandomCode();
dt_verifyImage.BackColor = ColorTranslator.FromHtml("#edf8fe");
Session["SystemCode"] = dt_verifyImage._Code;
///����û�л���
Response.Buffer = true;
Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
Response.Expires = 0;
Response.CacheControl = "no-cache";
Response.AppendHeader("Pragma", "No-Cache");
Bitmap objBitmap = dt_verifyImage.GetVerifyImage();
objBitmap.Save(Response.OutputStream, ImageFormat.Gif);
if (null != objBitmap)
objBitmap.Dispose();
Response.ContentType = "image/gif";
Response.Write(Response.OutputStream);
}
示例7: AddHeadersToEnable403Cacheing
private void AddHeadersToEnable403Cacheing(HttpResponse response)
{
var browser = HttpContext.Current.Request.Browser;
if (browser.IsBrowser("IE") && (browser.MajorVersion <= 6))
{
// Turn off caching due to issues with IE 6.0
response.Cache.SetCacheability(HttpCacheability.NoCache);
response.Cache.SetNoStore();
}
else
{
response.AppendHeader("Last-Modified", serverFingerprint.LastModifiedTime.ToString("r"));
response.AppendHeader("ETag", serverFingerprint.ETag);
response.AppendHeader("Cache-Control", "no-store");
}
}
示例8: MakePageExpired
//public static void DisableMasterPageStamp(Page page)
//{
// Validate.NotNull(page, "page");
// if (page.Master != null)
// {
// Control ctrl = page.Master.FindControl(DoubleSubmitStamp.MasterPageControlName);
// if (ctrl != null)
// ((DoubleSubmitStamp) ctrl).RenderStamp = false;
// }
//}
public static void MakePageExpired(HttpResponse response)
{
Validate.NotNull(response, "response");
response.Expires = 0;
response.Cache.SetNoStore();
response.AppendHeader("Pragma", "no-cache");
}
示例9: GZipEncodePage
public static void GZipEncodePage(HttpRequest Request, HttpResponse Response)
{
if (!IsGZipSupported(Request)) return;
string AcceptEncoding = Request.Headers["Accept-Encoding"];
if (AcceptEncoding.Contains("gzip"))
{
Response.Filter = new System.IO.Compression.GZipStream(Response.Filter, System.IO.Compression.CompressionMode.Compress);
Response.AppendHeader("Content-Encoding", "gzip");
}
else
{
Response.Filter = new System.IO.Compression.DeflateStream(Response.Filter, System.IO.Compression.CompressionMode.Compress);
Response.AppendHeader("Content-Encoding", "deflate");
}
}
示例10: SetResponseHeader
private static void SetResponseHeader(HttpResponse response, string buildVersion)
{
if (WebVersionConfiguration.Settings.SendResponseHeader)
{
response.AppendHeader("X-Web-Version", buildVersion);
}
}
示例11: MapResponseToHttpResponse
private static void MapResponseToHttpResponse(Response response, HttpResponse httpResponse)
{
response.Headers.ForEach(header => httpResponse.AppendHeader(header.Key, header.Value));
httpResponse.StatusCode = response.StatusCode;
httpResponse.ContentType = response.ContentType;
response.Contents.Invoke(httpResponse.OutputStream);
}
示例12: EncodeStreamAndAppendResponseHeaders
public static void EncodeStreamAndAppendResponseHeaders(HttpResponse response, string acceptEncoding)
{
if (acceptEncoding == null) return;
var preferredEncoding = ParsePreferredEncoding(acceptEncoding);
if (preferredEncoding == null) return;
response.AppendHeader("Content-Encoding", preferredEncoding);
response.AppendHeader("Vary", "Accept-Encoding");
if (preferredEncoding == "deflate")
{
response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress, true);
}
if (preferredEncoding == "gzip")
{
response.Filter = new GZipStream(response.Filter, CompressionMode.Compress, true);
}
}
示例13: SendToResponse
/// <summary>
/// Sends the file to the response with content-length header
/// Works with all types of files, not image specific
/// </summary>
/// <param name="response"></param>
/// <param name="file"></param>
/// <param name="mimetype"></param>
private static void SendToResponse(HttpResponse response, byte[] fileContent, DateTime lastWriteTime, string mimetype)
{
response.ClearHeaders();
setCacheHeaders(response);
response.Cache.SetLastModified(lastWriteTime); // to avoid rounding problems with header (no millisecs there)
response.ContentType = mimetype;
response.AppendHeader("Content-Length", fileContent.Length.ToString());
response.BinaryWrite(fileContent);
response.End();
}
示例14: Export
public virtual void Export(ContentItem item, ExportOptions options, HttpResponse response)
{
response.ContentType = GetContentType();
response.AppendHeader("Content-Disposition", "attachment;filename=" + GetExportFilename(item));
using (var output = GetTextWriter(response))
{
Export(item, options, output);
output.Flush();
}
response.End();
}
示例15: Render
public void Render(HttpResponse response)
{
string serializedItems = ToString();
response.Clear();
var calendarName = _calendarName.Replace(',', ' ');
response.AppendHeader("Content-Disposition",
String.Format("attachment; filename={0}.ics",
HttpUtility.UrlPathEncode(calendarName)));
response.ContentType = "text/calendar";
response.Write(serializedItems);
}