本文整理汇总了C#中HttpResponse.Write方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponse.Write方法的具体用法?C# HttpResponse.Write怎么用?C# HttpResponse.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponse
的用法示例。
在下文中一共展示了HttpResponse.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send412
/// <summary>
/// Creates and sends an HttpResponse packet for an exception, wraps it to an error 401
/// </summary>
private void Send412(HttpResponse response)
{
response.Status = "412";
response.Write("<html><head><title>412 Precondition Failed</title></head><body>");
response.Write("<h3>Precondition Failed (412)</h3>");
response.Write("Unable to find a necessary cookie, please ensure that your browser supports cookies and have them enabled.");
response.Write("</body></html>");
}
示例2: Minify
private static void Minify(HttpResponse response, string file, string ext)
{
string content = File.ReadAllText(file);
Minifier minifier = new Minifier();
if (ext == ".css")
{
CssSettings settings = new CssSettings() { CommentMode = CssComment.None };
response.Write(minifier.MinifyStyleSheet(content, settings));
}
else if (ext == ".js")
{
CodeSettings settings = new CodeSettings() { PreserveImportantComments = false };
response.Write(minifier.MinifyJavaScript(content, settings));
}
}
示例3: 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();
}
示例4: DownloadFile
/// <summary>
/// �������ؿ�
/// </summary>
/// <param name="argResp">����ҳ��</param>
/// <param name="argFileStream">�ļ���</param>
/// <param name="strFileName">�ļ���</param>
public static void DownloadFile(HttpResponse argResp, StringBuilder argFileStream, string strFileName)
{
try {
string strResHeader = "attachment; filename=" + Guid.NewGuid().ToString() + ".csv";
if (!string.IsNullOrEmpty(strFileName)) {
strResHeader = "inline; filename=" + strFileName;
}
argResp.AppendHeader("Content-Disposition", strResHeader);//attachment˵���Ը������أ�inline˵�����ߴ�
argResp.ContentType = "application/ms-excel";
argResp.ContentEncoding = Encoding.GetEncoding("GB2312"); // Encoding.UTF8;//
argResp.Write(argFileStream);
} catch (Exception ex) {
throw ex;
}
}
示例5: Output
public static void Output(HttpResponse Response)
{
Response.Write("<br/>HostingEnvironment.ApplicationPhysicalPath=" + System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath);
Response.Write("<br/>HostingEnvironment.ApplicationVirtualPath=" + System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
Response.Write("<br/>HostingEnvironment.SiteName=" + System.Web.Hosting.HostingEnvironment.SiteName + "\n");
//RazorGenerator.Mvc.EngineDebug.ListRoutes(Response);
try
{
var index = Microsoft.SourceBrowser.SourceIndexServer.Models.Index.Instance;
Response.Write(String.Format("<br/>Index.RootPath={0}\n", index.RootPath));
Response.Write(String.Format("<br/>Index.ProjPath={0}\n", index.ProjPath));
// RoutingModule.EnumerateHttpModules(url, Response);
}
catch (Exception ex) { Response.Write(String.Format("Route modules error {0}", ex.Message)); }
}
示例6: sendResponseAsJson
private void sendResponseAsJson(HttpResponse response, string responseString)
{
response.Clear();
response.BufferOutput = true;
response.StatusCode = 200; // HttpStatusCode.OK;
response.Write(responseString);
response.ContentType = "application/json; charset=utf-8";
response.End();
}
示例7: sendFile
private void sendFile(HttpResponse response, string fileName)
{
/*
* client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println();
*/
response.Clear();
response.BufferOutput = true;
response.StatusCode = 200; // HttpStatusCode.OK;
response.Write(SD.readAllFile(fileName));
response.ContentType = "text/html";
response.End();
}
示例8: 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();
}
}
示例9: ExportCSV
public static int numFieldOfImportFile = 16; //number column of import file
#endregion Fields
#region Methods
/// <summary>
/// Export data to csv and response directly
/// </summary>
/// <param name="response">Current page response</param>
/// <param name="fileName">export file name</param>
/// <param name="listData">list data to export</param>
public static void ExportCSV(HttpResponse response, string fileName, List<ImportExportFields> listData)
{
//prepare the output stream
response.Clear();
response.Buffer = true;
// response.ContentType = "text/csv";
response.ContentType = "application/octet-stream";//application/vnd.ms-excel";
response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}", fileName));
//response.ContentEncoding = Encoding.Unicode;
response.ContentEncoding = System.Text.Encoding.UTF8;
response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
response.Write(DataToCsvString(listData));
response.Flush();
response.End();
}
示例10: EnumRecursive
static void EnumRecursive(HttpResponse response, VirtualDirectory vdir) {
foreach (VirtualFile vfile in vdir.Files) {
response.Write("File: " + vfile.VirtualPath + "<br>\r\n");
}
foreach (VirtualDirectory childVdir in vdir.Directories) {
response.Write("Directory: " + childVdir.VirtualPath + "<br>\r\n");
EnumRecursive(response, childVdir);
}
}
示例11: LoadSimpleList
public static void LoadSimpleList(UInt32 OwnerID, HttpResponse Response)
{
db = new SQLDatabaseManager();
String query = "SELECT * FROM dbo.ANIMAL WHERE IDCLIENTE='" + OwnerID + "'";
DataTable temp;
temp = db.GetDataTable(query);
if (temp.Rows.Count < 1)
return;
foreach (DataRow r in temp.Rows)
{
Response.Write("<p> » <a href='\\Animal\\Animal?AnimalID=" + r["IDANIMAL"].ToString() + "'>" + r["NOME"].ToString() + "</a></p>");
}
}
示例12: LoadConsultas
public static void LoadConsultas(UInt32 IDClient, HttpResponse Response)
{
db = new SQLDatabaseManager();
String query = String.Format("SELECT * FROM dbo.MARCACAO WHERE IDCLIENTE='{0}' AND ESTADO<>'2'", IDClient);
DataTable temp;
temp = db.GetDataTable(query);
if(temp.Rows.Count == 0)
{
Response.Write("Não existem consultas agendadas.");
return;
}
}
示例13: ExportToCSV
private void ExportToCSV(string exportContent, HttpResponse response)
{
response.Clear();
response.AddHeader("content-disposition", "attachment;filename=" + fileName);
response.Charset = "";
response.ContentType = "application/octet-stream";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
response.Write(exportContent);
response.End();
}
示例14: 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();
}
示例15: LoadPayments
public static void LoadPayments(WebsiteUser Obj, HttpResponse Response)
{
String query = String.Format("SELECT * FROM dbo.PAGAMENTO WHERE IDCLIENTE='{0}'", Obj.ClientID);
DataTable temp;
temp = db.GetDataTable(query);
foreach(DataRow r in temp.Rows)
{
Response.Write("<div class='col-md-4'>");
Response.Write("<h4><u>Data: </u> " + r["DATA_LIMITE"].ToString().Remove(11) + "</h4>");
Response.Write("<p><a class='btn btn-default' href='\\Account\\Payments\\Payment?PaymentID=" + r["IDPAGAMENTO"].ToString() + "'>Detalhes »</a></p>");
Response.Write("</div>");
}
}