<%@ WebHandler Language="C#" Class="wx_login" %> using System; using System.Web; using System.Net; using Tencent; public class wx_login : IHttpHandler { public void ProcessRequest (HttpContext context) { string userId=""; Weixin wx = new Weixin(context); string surl = ""; string rurl = context.Request["state"]; string code = context.Request["code"]; if (!string.IsNullOrEmpty(code)) { wx.Messager.GetAccesstoken(); userId = wx.Messager.GetUserId(code); WeiXinWebCommon.SetCookieUserId(context, userId); /* context.Response.ContentType= "text/html"; context.Response.Write(""); context.Response.Write("
hi,"+ str + "
"); context.Response.Write("");*/ } context.Response.ContentType = "text/plain"; context.Response.Write(userId); context.Response.Write(code); context.Response.Redirect(rurl); } public bool IsReusable { get { return false; } } }