日期:2014-05-17 浏览次数:20474 次
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string postStr = "";
if (context.Request.HttpMethod.ToLower() == "post")
{
System.IO.Stream s = System.Web.HttpContext.Current.Request.InputStream;
byte[] b = new byte[s.Length];
s.Read(b, 0, (int)s.Length);
postStr = System.Text.Encoding.UTF8.GetString(b);
if (!string.IsNullOrEmpty(postStr))
{
ResponseMsg(postStr);
}
}
}
public void ResponseMsg(string weixinXML)
{
//回复消息的部分:你的代码写在这里
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(weixinXML);
System.Xml.XmlNodeList list = doc.GetElementsByTagName("xml");
System.Xml.XmlNode xn = list[0];
string FromUserName = xn.SelectSingleNode("//FromUserName").InnerText;
string ToUserName = xn.SelectSingleNode("//ToUserName").InnerText;
string content ="";
content = xn.SelectSingleNode("//Content").InnerText;
if (content.Equals("nihao"))