本文整理汇总了C#中HttpResponse.ClearHeaders方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponse.ClearHeaders方法的具体用法?C# HttpResponse.ClearHeaders怎么用?C# HttpResponse.ClearHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponse
的用法示例。
在下文中一共展示了HttpResponse.ClearHeaders方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteJsonData
//truyen json data len form
public static void WriteJsonData(HttpResponse response, Object obj)
{
response.Clear();
response.ClearContent();
response.ClearHeaders();
System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer { MaxJsonLength = Int32.MaxValue, RecursionLimit = 100 };
string output = oSerializer.Serialize(obj);
response.ContentType = "Application/Json";
response.Write(output);
response.End();
}
示例2: DownloadDocument
public static void DownloadDocument(HttpResponse httpResponse, byte[] fileContents, string fileName)
{
try
{
string contentType = "application/octet-stream";
try { contentType = Utilities.GetMimeType(System.IO.Path.GetExtension(fileName)); }
catch (Exception) { }
httpResponse.Clear();
httpResponse.ClearHeaders();
// add cooke so that javascript can detect when file downloaded is done and started if it want's to
// do something (such as letter print page to deselect leter to print)
httpResponse.Cookies["fileDownloaded"].Value = "true";
httpResponse.Cookies["fileDownloaded"].Expires = DateTime.Now.AddHours(3);
httpResponse.ContentType = contentType;
httpResponse.AddHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
httpResponse.OutputStream.Write(fileContents, 0, fileContents.Length);
httpResponse.Flush();
httpResponse.End();
}
catch (System.Web.HttpException ex)
{
// ignore exception where user closed the download box
if (!ex.Message.StartsWith("The remote host closed the connection. The error code is"))
throw;
}
}
示例3: ExportExcel
/// <summary>
/// Export excel with HTML format
/// </summary>
/// <param name="response">Current page response</param>
/// <param name="fileName">export file name</param>
/// <param name="tb">web html table</param>
public static void ExportExcel(HttpResponse response, string fileName, Table tb)
{
try
{
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer = true;
response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}", fileName));
response.Charset = "utf-8";
response.ContentEncoding = System.Text.Encoding.UTF8;
response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
tb.RenderControl(oHtmlTextWriter);
response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");
response.Write(AddExcelStyling());
string style = @"<style> .text { mso-number-format:\@; } </style>";
response.Write(style);
response.Write(oStringWriter.ToString());
response.End();
}
catch (Exception ex)
{
Pollinator.Common.Logger.Error("Error occured at " + typeof(ImportExportUltility).Name + " ExportExcel().:", ex);
response.End();
}
}