本文整理汇总了C#中System.Web.HttpResponse.Write方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponse.Write方法的具体用法?C# HttpResponse.Write怎么用?C# HttpResponse.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpResponse
的用法示例。
在下文中一共展示了HttpResponse.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequest
public override void ProcessRequest(HttpRequest req, HttpResponse res)
{
var type = typeof(CachedConfigContext);
var configContext = CachedConfigContext.Current;
if (string.IsNullOrEmpty(req["config"]))
{
res.Write("<p><h1>网站当前配置列表:</h1><p>");
foreach (var p in type.GetProperties())
{
if (p.Name != "ConfigService")
res.Write(string.Format("<p><a href='?config={0}' target='_blank'>{0} [点击查看]</a></p>", p.Name));
}
}
else
{
foreach (var p in type.GetProperties())
{
if (p.Name == req["config"] && p.Name != "DaoConfig")
{
var currentConfig = p.GetValue(configContext, null);
if (currentConfig != null)
{
res.ContentType = "text/xml";
res.ContentEncoding = System.Text.Encoding.UTF8;
res.Write(SerializationHelper.XmlSerialize(currentConfig));
break;
}
}
}
}
}
示例2: ReplyError
private void ReplyError(HttpStatusCode statusCode, string text, HttpResponse response)
{
response.StatusCode = (int)statusCode;
response.ContentType = "text/html";
response.Write(String.Format("<html><title>MovieInfo : ERROR</title><body><p>{0}</p></body></html>", text));
for (int i = 0; i < 85; ++i) response.Write(" ");
}
开发者ID:sandrapatfer,项目名称:PROMPT11-07-ConcurrentProgramming.sandrapatfer,代码行数:7,代码来源:MovieInfoTPL2Handler.cs
示例3: Read
/// <summary>
/// The purpose of this page is to service JSON Files. The files are already generated
/// elsewhere and are loaded from file system.
///
/// A query string parameter is sent to this page. Given name of 'm' and has values of '1:Get movies' file,
/// '2:Get Movies Catalog' and so on.
/// </summary>
public static void Read(HttpRequest Request, HttpResponse Response)
{
string fileNameMovies = @"D:\SitiosWeb\Sitio\EC100A_Servicios\EC100A_PlanepolyWidget\planepoly-movies.json";
string fileNameMoviesCatalog = @"D:\SitiosWeb\Sitio\EC100A_Servicios\EC100A_PlanepolyWidget\planepoly-movies-catalog.json";
string fileName = "";
string m = Request.QueryString["m"];
if (m == null || (m != "1" && m != "2"))
{
Response.Write("Invalid");
return;
}
switch (m)
{
case "1":
fileName = fileNameMovies;
break;
case "2":
fileName = fileNameMoviesCatalog;
break;
default:
break;
}
string s;
using (StreamReader reader = new StreamReader(fileName))
{
s = reader.ReadToEnd();
}
Response.Write(s);
Response.AddHeader("Access-Control-Allow-Origin", "*");
}
示例4: CloseIt
public static void CloseIt(HttpResponse response)
{
response.Clear();
response.Write("<script type=\"text/javascript\">");
response.Write("window.close();");
response.Write("</script>");
response.End();
}
示例5: WriteErrorInfo
/// <summary>
/// This method will check for "directive=debug" in the querystring to indicate debugging mode. If we're
/// in debugging mode, the error message and stack trace will be written to the page and the response will be ended.
/// </summary>
/// <param name="response"></param>
/// <param name="request"></param>
/// <param name="exception"></param>
public static void WriteErrorInfo(HttpResponse response, HttpRequest request, Exception exception)
{
if (IsDebugMode(response, request))
{
response.Write("<b>Message:</b> " + exception.Message + "<br /><br />");
response.Write("<b>Stack Trace:</b> " + exception.StackTrace.Replace("\n", "<br />"));
response.End();
}
}
示例6: create_end_of_table
///////////////////////////////////////////////////////////////////////
public static void create_end_of_table(
HttpResponse r)
{
// data
r.Write("</table>\n");
r.Write("</div>\n");
r.Write("<div id=sortedby> </div>\n");
}
示例7: create_start_of_table
///////////////////////////////////////////////////////////////////////
public static void create_start_of_table(
HttpResponse r)
{
r.Write("\n<div id=wait class=please_wait> </div>\n");
r.Write("<div class=click_to_sort>click on column headings to sort</div>\n");
r.Write("<div id=myholder>\n");
//r.Write ("<table id=mytable class=datat border=1 cellspacing=0 cellpadding=2>\n");
r.Write("<table id=mytable border=1 class=datat>\n");
}
示例8: WriteResponse
public override void WriteResponse(HttpResponse response)
{
response.ContentType = "text/html";
response.Charset = "UTF-8";
if(myXhtml != null) response.Write(myXhtml.OuterXml);
if(myMessage != null){
myXhtml.Body.AppendChild(myXhtml.CreateTextNode(myMessage));
response.Write(myXhtml.OuterXml);
}
for(int i=0; i < this.Cookies.Count; i++){
response.Cookies.Add(this.Cookies[i]);
}
}
示例9: ToExcel
public static void ToExcel(HttpResponse Response,DataTable dt , string fileName)
{
Response.ContentType = "application/csv";
Response.Charset = "";
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
Response.ContentEncoding = Encoding.Unicode;
Response.BinaryWrite(Encoding.Unicode.GetPreamble());
try
{
StringBuilder sb = new StringBuilder();
//Add Header
for (int count = 0; count < dt.Columns.Count - 1; count++)
{
if (dt.Columns[count].ColumnName != null)
sb.Append(dt.Columns[count].ColumnName);
sb.Append("\t");
}
Response.Write(sb.ToString() + "\n");
Response.Flush();
//Append Data
int index = 0;
while (dt.Rows.Count >= index + 1)
{
sb = new StringBuilder();
for (int col = 0; col < dt.Columns.Count -1; col++)
{
if (dt.Rows[index][col] != null)
//sb.Append(dt.Rows[index][col].ToString().Replace(",", " "));
sb.Append(dt.Rows[index][col].ToString());
sb.Append("\t");
}
Response.Write(sb.ToString() + "\n");
Response.Flush();
index = index + 1;
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
dt.Dispose();
Response.End();
}
示例10: create_start_of_table
///////////////////////////////////////////////////////////////////////
public static void create_start_of_table(
HttpResponse r, bool write_column_headings_as_links)
{
if (write_column_headings_as_links)
{
r.Write("\n<div id=wait class=please_wait> </div>\n");
r.Write("<div class=click_to_sort>click on column headings to sort</div>\n");
}
r.Write("<div id=myholder>\n");
r.Write("<table id=mytable border=1 class=datat>\n");
}
示例11: DoGet
public void DoGet(HttpRequest req, HttpResponse resp)
{
resp.ContentType = "application/json";
string command = "SELECT account, balance " +
"FROM ACCTS WHERE id=" + req.Params[
ConfigurationManager.AppSettings["request.parametername"]];
SqlDataAdapter dataAdapter = new SqlDataAdapter(command,
ConfigurationManager.AppSettings["handler.serverstring"]);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet, "ACCTS");
DataTable dataTable = dataSet.Tables[0];
try
{
float totalBalance = 0;
int rowNum = 0;
resp.Write("{\"balances\":[");
while (dataTable.Rows.GetEnumerator().MoveNext())
{
rowNum++;
DataRow results = (DataRow)dataTable.Rows.GetEnumerator().Current;
// Assuming result is 9-digit bank account number,
// validate with 11-test:
int sum = 0;
for (int i = 0; i < ((string)results["account"]).Length; i++)
{
sum = sum + (9 - i) *
(int)Char.GetNumericValue(((string)results["account"])[i]);
}
if (sum % 11 == 0)
{
totalBalance += (float)results["balance"];
resp.Write($"{{\"{results["account"]}\":{results["balance"]}}}");
}
if (rowNum == dataTable.Rows.Count)
{
resp.Write("],\n");
}
else
{
resp.Write(",");
}
}
resp.Write($"\"total\":{totalBalance}}}\n");
}
catch (SqlException e)
{
Console.WriteLine($"SQL exception: {e.Message}");
}
}
示例12: WriteResponse
/// <summary>
/// 渡された HttpResponse にレスポンスを書き込みます。
/// このメソッドは何度も使われるため、Html に AppendChild してはいけません。
/// </summary>
public override void WriteResponse(HttpResponse response){
WriteResponseHeader(response);
SetLastModified(response);
// HTML にメッセージを投入
if(Html == null){
response.Write("<plaintext>");
response.Write(myMessage);
} else {
// XmlElement mes = Html.P(null, myMessage);
// Html.Append(mes);
response.Write(Html.OuterXml);
}
}
示例13: ExportToExcelFile
/// <summary>
/// Exporta la información a Excel.
/// </summary>
/// <param name="response">HttpResponse actual.</param>
/// <param name="data">Datos a exportar.</param>
/// <param name="nombreArchivo">Nombre del archivo Excel</param>
public static void ExportToExcelFile(HttpResponse response, DataView data, string nombreArchivo)
{
var dg = new DataGrid { DataSource = data };
dg.DataBind();
response.Clear();
response.Buffer = true;
//application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
response.AddHeader("Content-Disposition", "filename=" + nombreArchivo);
response.ContentType = "application/vnd.ms-excel";
response.Charset = "UTF-8";
response.ContentEncoding = System.Text.Encoding.Default;
var stringWriter = new StringWriter();
var htmlWriter = new HtmlTextWriter(stringWriter);
dg.RenderControl(htmlWriter);
response.Write(stringWriter.ToString());
//resp.Flush();
try
{
response.End();
}
catch (Exception ex)
{
ISException.RegisterExcepcion(ex);
throw ex;
}
}
示例14: OpenInNewWindows
/// <summary>
///
/// </summary>
/// <param name="url"></param>
public static void OpenInNewWindows(HttpResponse response, string url)
{
string s = string.Format(
"<script type='text/javascript' language='javascript'>window.open('{0}')</script>",
url);
response.Write(s);
}
示例15: displayEdit
public void displayEdit(HttpRequest request, HttpResponse response)
{
String itemId = request["itemId"];
TextBox x = new TextBox();
response.Write(calendarManager.findEventDetails(Int16.Parse(itemId)));
}