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


C# HttpServerResponse.Write方法代码示例

本文整理汇总了C#中HttpServerResponse.Write方法的典型用法代码示例。如果您正苦于以下问题:C# HttpServerResponse.Write方法的具体用法?C# HttpServerResponse.Write怎么用?C# HttpServerResponse.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpServerResponse的用法示例。


在下文中一共展示了HttpServerResponse.Write方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OutputCredentialsForm

		private static void OutputCredentialsForm (HttpServerResponse resp, string Message)
		{
			resp.Write ("<html><head><title>Actuator</title></head><body><form method='POST' action='/credentials' target='_self' autocomplete='true'>");
			resp.Write (Message);
			resp.Write ("<h1>Update Login Credentials</h1><p><label for='UserName'>User Name:</label><br/><input type='text' name='UserName'/></p>");
			resp.Write ("<p><label for='Password'>Password:</label><br/><input type='password' name='Password'/></p>");
			resp.Write ("<p><label for='NewUserName'>New User Name:</label><br/><input type='text' name='NewUserName'/></p>");
			resp.Write ("<p><label for='NewPassword1'>New Password:</label><br/><input type='password' name='NewPassword1'/></p>");
			resp.Write ("<p><label for='NewPassword2'>New Password again:</label><br/><input type='password' name='NewPassword2'/></p>");
			resp.Write ("<p><input type='submit' value='Update'/></p></form></body></html>");
		}
开发者ID:wrtcoder,项目名称:Learning-IoT-MQTT,代码行数:11,代码来源:Program.cs

示例2: HttpGetSet

		private static void HttpGetSet (HttpServerResponse resp, HttpServerRequest req)
		{
			string s;
			int i;
			bool b;

			foreach (KeyValuePair<string,string> Query in req.Query)
			{
				if (!XmlUtilities.TryParseBoolean (Query.Value, out b))
					continue;

				s = Query.Key.ToLower ();
				if (s == "alarm")
				{
					if (b)
					{
						AlarmOn ();
						state.Alarm = true;
					} else
					{
						AlarmOff ();
						state.Alarm = false;
					}
				} else if (s.StartsWith ("do") && int.TryParse (s.Substring (2), out i) && i >= 1 && i <= 8)
				{
					digitalOutputs [i - 1].Value = b;
					state.SetDO (i, b);
				}
			}

			state.UpdateIfModified ();

			resp.ContentType = "text/html";
			resp.Encoding = System.Text.Encoding.UTF8;
			resp.ReturnCode = HttpStatusCode.Successful_OK;

			resp.Write ("<html><head><title>Actuator</title></head><body><h1>Control Actuator Outputs</h1>");
			resp.Write ("<form method='POST' action='/set' target='_self'><p>");

			for (i = 0; i < 8; i++)
			{
				resp.Write ("<input type='checkbox' name='do");
				resp.Write ((i + 1).ToString ());
				resp.Write ("'");
				if (digitalOutputs [i].Value)
					resp.Write (" checked='checked'");
				resp.Write ("/> Digital Output ");
				resp.Write ((i + 1).ToString ());
				resp.Write ("<br/>");
			}

			resp.Write ("<input type='checkbox' name='alarm'");
			if (alarmThread != null)
				resp.Write (" checked='checked'");
			resp.Write ("/> Alarm</p>");
			resp.Write ("<p><input type='submit' value='Set'/></p></form></body></html>");
		}
开发者ID:wrtcoder,项目名称:Learning-IoT-MQTT,代码行数:57,代码来源:Program.cs

示例3: HttpGetHtml

		private static void HttpGetHtml (HttpServerResponse resp, HttpServerRequest req)
		{
			networkLed.High ();
			try
			{
				string SessionId = req.Header.GetCookie ("SessionId");
				if (!CheckSession (SessionId))
					throw new HttpTemporaryRedirectException ("/");

				resp.ContentType = "text/html";
				resp.Encoding = System.Text.Encoding.UTF8;
				resp.Expires = DateTime.Now;
				resp.ReturnCode = HttpStatusCode.Successful_OK;

				resp.Write ("<html><head><meta http-equiv='refresh' content='60'/><title>Sensor Readout</title></head><body><h1>Readout, ");
				resp.Write (DateTime.Now.ToString ());
				resp.Write ("</h1><table><tr><td>Temperature:</td><td style='width:20px'/><td>");

				lock (synchObject)
				{
					resp.Write (HtmlUtilities.Escape (temperatureC.ToString ("F1")));
					resp.Write (" C</td></tr><tr><td>Light:</td><td/><td>");
					resp.Write (HtmlUtilities.Escape (lightPercent.ToString ("F1")));
					resp.Write (" %</td></tr><tr><td>Motion:</td><td/><td>");
					resp.Write (motionDetected.ToString ());
					resp.Write ("</td></tr></table>");

					if (perSecond.Count > 1)
					{
						resp.Write ("<h2>Second Precision</h2><table><tr><td><img src='historygraph?p=temp&base=sec&w=350&h=250' width='480' height='320'/></td>");
						resp.Write ("<td style='width:20px'/><td><img src='historygraph?p=light&base=sec&w=350&h=250' width='480' height='320'/></td>");
						resp.Write ("<td style='width:20px'/><td><img src='historygraph?p=motion&base=sec&w=350&h=250' width='480' height='320'/></td></tr></table>");

						if (perMinute.Count > 1)
						{
							resp.Write ("<h2>Minute Precision</h2><table><tr><td><img src='historygraph?p=temp&base=min&w=350&h=250' width='480' height='320'/></td>");
							resp.Write ("<td style='width:20px'/><td><img src='historygraph?p=light&base=min&w=350&h=250' width='480' height='320'/></td>");
							resp.Write ("<td style='width:20px'/><td><img src='historygraph?p=motion&base=min&w=350&h=250' width='480' height='320'/></td></tr></table>");

							if (perHour.Count > 1)
							{
								resp.Write ("<h2>Hour Precision</h2><table><tr><td><img src='historygraph?p=temp&base=h&w=350&h=250' width='480' height='320'/></td>");
								resp.Write ("<td style='width:20px'/><td><img src='historygraph?p=light&base=h&w=350&h=250' width='480' height='320'/></td>");
								resp.Write ("<td style='width:20px'/><td><img src='historygraph?p=motion&base=h&w=350&h=250' width='480' height='320'/></td></tr></table>");

								if (perDay.Count > 1)
								{
									resp.Write ("<h2>Day Precision</h2><table><tr><td><img src='historygraph?p=temp&base=day&w=350&h=250' width='480' height='320'/></td>");
									resp.Write ("<td style='width:20px'/><td><img src='historygraph?p=light&base=day&w=350&h=250' width='480' height='320'/></td>");
									resp.Write ("<td style='width:20px'/><td><img src='historygraph?p=motion&base=day&w=350&h=250' width='480' height='320'/></td></tr></table>");

									if (perMonth.Count > 1)
									{
										resp.Write ("<h2>Month Precision</h2><table><tr><td><img src='historygraph?p=temp&base=month&w=350&h=250' width='480' height='320'/></td>");
										resp.Write ("<td style='width:20px'/><td><img src='historygraph?p=light&base=month&w=350&h=250' width='480' height='320'/></td>");
										resp.Write ("<td style='width:20px'/><td><img src='historygraph?p=motion&base=month&w=350&h=250' width='480' height='320'/></td></tr></table>");
									}
								}
							}
						}
					}
				}

				resp.Write ("</body><html>");

			} finally
			{
				networkLed.Low ();
			}
		}
开发者ID:mukira,项目名称:Learning-IoT-HTTP,代码行数:70,代码来源:Program.cs

示例4: HttpGetRoot

		private static void HttpGetRoot (HttpServerResponse resp, HttpServerRequest req)
		{
			string SessionId = req.Header.GetCookie ("SessionId");

			resp.ContentType = "text/html";
			resp.Encoding = System.Text.Encoding.UTF8;
			resp.ReturnCode = HttpStatusCode.Successful_OK;

			if (CheckSession (SessionId))
			{
				resp.Write ("<html><head><title>Actuator</title></head><body><h1>Welcome to Actuator</h1><p>Below, choose what you want to do.</p><ul>");
				resp.Write ("<li><a href='/credentials'>Update login credentials.</a></li>");
				resp.Write ("<li><a href='/set'>Control Outputs</a></li>");
				resp.Write ("<li>View Output States</li><ul>");
				resp.Write ("<li><a href='/xml?Momentary=1'>View data as XML using REST</a></li>");
				resp.Write ("<li><a href='/json?Momentary=1'>View data as JSON using REST</a></li>");
				resp.Write ("<li><a href='/turtle?Momentary=1'>View data as TURTLE using REST</a></li>");
				resp.Write ("<li><a href='/rdf?Momentary=1'>View data as RDF using REST</a></li></ul>");
				resp.Write ("</ul></body></html>");

			} else
				OutputLoginForm (resp, string.Empty);
		}
开发者ID:wrtcoder,项目名称:Learning-IoT-MQTT,代码行数:23,代码来源:Program.cs

示例5: HttpGetRoot

		private static void HttpGetRoot (HttpServerResponse resp, HttpServerRequest req)
		{
			networkLed.High ();
			try
			{
				string SessionId = req.Header.GetCookie ("SessionId");

				resp.ContentType = "text/html";
				resp.Encoding = System.Text.Encoding.UTF8;
				resp.ReturnCode = HttpStatusCode.Successful_OK;

				if (CheckSession (SessionId))
				{
					StringBuilder sb = new StringBuilder ();
					string EventParameters;

					lock (synchObject)
					{
						sb.Append ("?Temperature=");
						sb.Append (XmlUtilities.DoubleToString (temperatureC, 1));
						sb.Append ("&amp;TemperatureDiff=1&amp;Light=");
						sb.Append (XmlUtilities.DoubleToString (lightPercent, 1));
						sb.Append ("&amp;LightDiff=10&amp;Motion=");
						sb.Append (motionDetected ? "1" : "0");
						sb.Append ("&amp;Timeout=25");
					}

					EventParameters = sb.ToString ();

					resp.Write ("<html><head><title>Sensor</title></head><body><h1>Welcome to Sensor</h1><p>Below, choose what you want to do.</p><ul>");
					resp.Write ("<li><a href='/credentials'>Update login credentials.</a></li>");
					resp.Write ("<li>View Data</li><ul>");
					resp.Write ("<li><a href='/xml?Momentary=1'>View data as XML using REST</a></li>");
					resp.Write ("<li><a href='/json?Momentary=1'>View data as JSON using REST</a></li>");
					resp.Write ("<li><a href='/turtle?Momentary=1'>View data as TURTLE using REST</a></li>");
					resp.Write ("<li><a href='/rdf?Momentary=1'>View data as RDF using REST</a></li>");
					resp.Write ("<li><a href='/html'>Data in a HTML page with graphs</a></li></ul>");
					resp.Write ("<li>Wait for an Event</li><ul>");
					resp.Write ("<li><a href='/event/xml");
					resp.Write (EventParameters);
					resp.Write ("'>Return XML data when event occurs.</a></li>");
					resp.Write ("<li><a href='/event/json");
					resp.Write (EventParameters);
					resp.Write ("'>Return JSON data when event occurs.</a></li>");
					resp.Write ("<li><a href='/event/turtle");
					resp.Write (EventParameters);
					resp.Write ("'>Return TURTLE data when event occurs.</a></li>");
					resp.Write ("<li><a href='/event/rdf");
					resp.Write (EventParameters);
					resp.Write ("'>Return RDF data when event occurs.</a></li>");
					resp.Write ("</ul></body></html>");

				} else
					OutputLoginForm (resp, string.Empty);
			} finally
			{
				networkLed.Low ();
			}
		}
开发者ID:mukira,项目名称:Learning-IoT-HTTP,代码行数:59,代码来源:Program.cs

示例6: OutputLoginForm

		private static void OutputLoginForm (HttpServerResponse resp, string Message)
		{
			resp.Write ("<html><head><title>Sensor</title></head><body><form method='POST' action='/' target='_self' autocomplete='true'>");
			resp.Write (Message);
			resp.Write ("<h1>Login</h1><p><label for='UserName'>User Name:</label><br/><input type='text' name='UserName'/></p>");
			resp.Write ("<p><label for='Password'>Password:</label><br/><input type='password' name='Password'/></p>");
			resp.Write ("<p><input type='submit' value='Login'/></p></form></body></html>");
		}
开发者ID:mukira,项目名称:Learning-IoT-HTTP,代码行数:8,代码来源:Program.cs

示例7: HttpGetCameraDevice

		private static void HttpGetCameraDevice (HttpServerResponse resp, HttpServerRequest req)
		{
			networkLed.High ();
			try
			{
				string Xml;
				byte[] Data;
				int c;

				using (Stream stream = Assembly.GetExecutingAssembly ().GetManifestResourceStream ("Camera.UPnP.CameraDevice.xml"))
				{
					c = (int)stream.Length;
					Data = new byte[c];
					stream.Position = 0;
					stream.Read (Data, 0, c);
					Xml = TextDecoder.DecodeString (Data, System.Text.Encoding.UTF8);
				}

				string HostName = System.Net.Dns.GetHostName ();
				System.Net.IPHostEntry HostEntry = System.Net.Dns.GetHostEntry (HostName);

				foreach (System.Net.IPAddress Address in HostEntry.AddressList)
				{
					if (Address.AddressFamily == req.ClientEndPoint.AddressFamily)
					{
						Xml = Xml.Replace ("{IP}", Address.ToString ());
						break;
					}
				}

				Xml = Xml.Replace ("{PORT}", upnpServer.Port.ToString ());
				Xml = Xml.Replace ("{UDN}", defaultSettings.UDN);

				resp.ContentType = "text/xml";
				resp.Encoding = System.Text.Encoding.UTF8;
				resp.ReturnCode = HttpStatusCode.Successful_OK;

				resp.Write(Xml);

			} finally
			{
				networkLed.Low ();
			}
		}
开发者ID:wrtcoder,项目名称:Learning-IoT-MQTT,代码行数:44,代码来源:Program.cs

示例8: HttpGetHtml

		private static void HttpGetHtml (HttpServerResponse resp, HttpServerRequest req, bool Protected)
		{
			networkLed.High ();
			try
			{
				LinkSpriteJpegColorCamera.ImageSize Resolution;
				string Encoding;
				byte Compression;

				if (Protected)
				{
					string SessionId = req.Header.GetCookie ("SessionId");
					if (!CheckSession (SessionId))
						throw new HttpTemporaryRedirectException ("/");
				}

				GetImageProperties (req, out Encoding, out Compression, out Resolution);

				resp.ContentType = "text/html";
				resp.Encoding = System.Text.Encoding.UTF8;
				resp.Expires = DateTime.Now;
				resp.ReturnCode = HttpStatusCode.Successful_OK;

				resp.Write ("<html><head/><body><h1>Camera, ");
				resp.Write (DateTime.Now.ToString ());
				resp.Write ("</h1><img src='camera?Encoding=");
				resp.Write (Encoding);
				resp.Write ("&Compression=");
				resp.Write (Compression.ToString ());
				resp.Write ("&Resolution=");
				resp.Write (Resolution.ToString ().Substring (1));
				resp.Write ("' width='640' height='480'/>");
				resp.Write ("</body><html>");

			} finally
			{
				networkLed.Low ();
			}
		}
开发者ID:wrtcoder,项目名称:Learning-IoT-MQTT,代码行数:39,代码来源:Program.cs

示例9: Write

        internal void Write(HttpServerResponse httpResponse)
        {
            httpResponse.WriteHead(_statusCode, _headers);

            if (_content != null) {
                httpResponse.Write(_content, Encoding.UTF8);
            }

            httpResponse.End();
        }
开发者ID:nikhilk,项目名称:simplecloud,代码行数:10,代码来源:ServerResponse.cs


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