1.首先根据appid 获取到预授权码的code
string Appid = "******";//appid。由于网页授权与js-jdk使用不同微信,所以暂时独立于此处。 string redirect_uri = "*********";//这里是回调地址的url string state = filterContext.HttpContext.Request.Url.ToString();//这里的state是 state = state.Replace("?", "|").Replace("&", "!!"); string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Appid + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=" + state + "#wechat_redirect"; filterContext.HttpContext.Response.Redirect(url);