⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaulthandler.ashx.cs

📁 帮助你了解AJAX的核心
💻 CS
字号:
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Xml;

namespace Linkedu.Web.WebWWW
{
    /// <summary>
    /// Summary description for $codebehindclassname$
    /// </summary>
    public class DefaultHandler : IHttpHandler
    {
        protected XmlDocument _xmlResult;

        public void ProcessRequest(HttpContext context)
        {
            if (context.Request["T"] != null)
            {//GET xmlhttp测试
                context.Response.ContentType = "text/xml";
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(string.Format(@"<time>GET:{0}</time>", System.DateTime.Now));
                xmlDoc.Save(context.Response.OutputStream);
                context.Response.End();
            }
            else
            {//POST xmlhttp测试
                context.Response.ContentType = "text/xml";
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(context.Request.InputStream);
                if (xmlDoc.DocumentElement.Name == "T")
                {
                    xmlDoc.LoadXml(string.Format(@"<time>POST:{0}</time>", System.DateTime.Now));
                    xmlDoc.Save(context.Response.OutputStream);
                    context.Response.End();
                }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -