/// <summary>处理请求</summary> /// <param name="context">上下文环境</param> public virtual void ProcessRequest(HttpContext context) { string outString = null; Hashtable args = new Hashtable(); try { bool sleep = (context.Request.Form["sleep"] == null) ? false : true; if (sleep) { Thread.Sleep(3000); } string xml = (context.Request.Form["xml"] == null) ? string.Empty : context.Request.Form["xml"]; if (!string.IsNullOrEmpty(xml)) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); string action = XmlHelper.Fetch("action", doc); string clientTargetObject = XmlHelper.Fetch("clientTargetObject", doc); string xslt = XmlHelper.Fetch("xslt", doc); args.Add("action", action); args.Add("xslt", xslt); if (!string.IsNullOrEmpty(action)) { this.resultType = (context.Request.Form["resultType"] == null) ? "json" : context.Request.Form["resultType"]; outString = AjaxMethodParser.Parse(this, action, doc); if (this.resultType == "json" && outString.IndexOf("\"message\":") > -1 && !string.IsNullOrEmpty(clientTargetObject)) { outString = outString.Insert(outString.IndexOf("\"message\":"), "\"clientTargetObject\":\"" + clientTargetObject + "\","); } } } } catch (Exception ex) { this.resultType = "json"; GenericException exception = new GenericException("-1", ex); outString = exception.ToString(); } // 输出信息 this.Export(context, this.resultType, outString, args); }
public void Reqeuest() { string action = "ajaxMethod"; string result = AjaxMethodParser.Parse(this, action, new XmlDocument()); }