Example #1
0
        public static ActionResult SendXml(this HttpListenerResponse response, XmlResponse r)
        {
            //buffer 100kb
            byte[] buffer = new byte[r.BufferSize];
            //content type
            response.ContentType = "text/xml";
            //string resource
            string content = r.Content;

            //open output stream
            using (var net = response.OutputStream)
            {
                using (Stream st = new MemoryStream(r.Encode.GetBytes(content)))
                {
                    while (true)
                    {
                        int count = st.Read(buffer, 0, buffer.Length);
                        if (count <= 0)
                        {
                            break;
                        }
                        net.Write(buffer, 0, count);
                    }
                }
            }            //end write

            return(ActionResult.Handled);
        }
Example #2
0
        public static ActionResult SendCrossDomainXml(this HttpListenerResponse response)
        {
            var r = new XmlResponse()
            {
                Content =
                    @"<?xml version=""1.0""?>
<cross-domain-policy>
  <allow-access-from domain=""*"" />
</cross-domain-policy>"
            };

            return(response.SendXml(r));
        }
Example #3
0
		public static ActionResult SendXml(this HttpListenerResponse response, XmlResponse r)
		{
			//buffer 100kb
			byte[] buffer = new byte[r.BufferSize];
			//content type
			response.ContentType = "text/xml";
			//string resource
			string content = r.Content;

			//open output stream
			using (var net = response.OutputStream)
			{
				using (Stream st = new MemoryStream(r.Encode.GetBytes(content)))
				{
					while (true)
					{
						int count = st.Read(buffer, 0, buffer.Length);
						if (count <= 0)
							break;
						net.Write(buffer, 0, count);
					}
				}
			}//end write

			return ActionResult.Handled;
		}
Example #4
0
		public static ActionResult SendCrossDomainXml(this HttpListenerResponse response)
		{
			var r = new XmlResponse()
			{
				Content = 
@"<?xml version=""1.0""?>
<cross-domain-policy>
  <allow-access-from domain=""*"" />
</cross-domain-policy>"
			};
			return response.SendXml(r);
		}