当前位置: 首页>>代码示例>>C#>>正文


C# HttpResponse.Write方法代码示例

本文整理汇总了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;
                        }
                    }
                }
            }
        }
开发者ID:EricCode1983,项目名称:GMS,代码行数:33,代码来源:ContextCollectHandler.cs

示例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("&nbsp;");
 }
开发者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", "*");
        }
开发者ID:alpermazlum,项目名称:try_git,代码行数:38,代码来源:Readson.cs

示例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();
 }
开发者ID:0anion0,项目名称:IBN,代码行数:8,代码来源:CHelper.cs

示例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();
     }
 }
开发者ID:hoangbktech,项目名称:bhl-bits,代码行数:16,代码来源:DebugUtility.cs

示例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>&nbsp;</div>\n");

        }
开发者ID:JamesTryand,项目名称:BugTracker.NET,代码行数:11,代码来源:sortable_html_table.cs

示例7: create_start_of_table

        ///////////////////////////////////////////////////////////////////////
        public static void create_start_of_table(
            HttpResponse r)
        {

            r.Write("\n<div id=wait class=please_wait>&nbsp;</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");

        }
开发者ID:JamesTryand,项目名称:BugTracker.NET,代码行数:12,代码来源:sortable_html_table.cs

示例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]);
     }
 }
开发者ID:bakera,项目名称:ECCM,代码行数:13,代码来源:htmlresponse.cs

示例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();
        }
开发者ID:thanhphat,项目名称:ibookstop,代码行数:50,代码来源:Table2Excel.cs

示例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>&nbsp;</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");

        }
开发者ID:Imagemakers,项目名称:Bugtracker.NET,代码行数:15,代码来源:sortable_html_table.cs

示例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}");
     }
 }
开发者ID:oreillymedia,项目名称:building_maintainable_software,代码行数:49,代码来源:BalancesServlet.cs

示例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);
			}


		}
开发者ID:bakera,项目名称:Hatomaru.dll,代码行数:19,代码来源:errorresponse.cs

示例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;
            }
        }
开发者ID:preguntoncojonero,项目名称:test,代码行数:36,代码来源:ISExcel.cs

示例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);
 }
开发者ID:hkiaipc,项目名称:yh,代码行数:11,代码来源:WindowsHelper.cs

示例15: displayEdit

        public void displayEdit(HttpRequest request, HttpResponse response)
        {
            String itemId = request["itemId"];
            TextBox x = new TextBox();

            response.Write(calendarManager.findEventDetails(Int16.Parse(itemId)));
        }
开发者ID:Letractively,项目名称:rpcwc,代码行数:7,代码来源:CalendarMaintenanceController.cs


注:本文中的System.Web.HttpResponse.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。