本文整理汇总了C#中HttpResponse.ClearContent方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponse.ClearContent方法的具体用法?C# HttpResponse.ClearContent怎么用?C# HttpResponse.ClearContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponse
的用法示例。
在下文中一共展示了HttpResponse.ClearContent方法的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: 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();
}
}
示例3: ExportToExcel
public static void ExportToExcel(HttpResponse response, DataSet ds)
{
NumberFormatInfo numInfo = Util.GetYankeeNumberFormat();
DataTable dt = ds.Tables[0];
response.ClearContent();
response.ContentEncoding = System.Text.Encoding.UTF8;
response.ContentType = "application/vnd.ms-excel";
string tab = "";
foreach (DataColumn dc in dt.Columns)
{
response.Write(tab + dc.ColumnName);
tab = "\t";
}
response.Write("\n");
int i;
foreach (DataRow dr in dt.Rows)
{
tab = "";
for (i = 0; i < dt.Columns.Count; i++)
{
switch (Util.GetMainTypeCode(dr[i].GetType()))
{
case MainTypeCodes.Number:
response.Write(tab + ((decimal)dr[i]).ToString("0.00#####", numInfo));
break;
case MainTypeCodes.DateTime:
response.Write(tab + ((DateTime)dr[i]).ToString("yyyy-MM-dd"));
break;
default:
response.Write(tab + dr[i].ToString());
break;
}
tab = "\t";
}
response.Write("\n");
}
response.End();
}