Generating the applet code (errcode: 41030) invalid page hint "Stream.Length" triggered "System.NotSupportedException" type of exception

   public string GetQrcode(string strToken, string content)
        {
            string strResult = "";
            string url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + strToken;
            System.Net.WebRequest wRequest = System.Net.WebRequest.Create(url);
            wRequest.Method = "post";
            wRequest.ContentType = "application/x-www-form-urlencoded";
            #region 添加Post 参数
            byte[] data = Encoding.UTF8.GetBytes(content);
            wRequest.ContentLength = data.Length;
            using (Stream reqStream = wRequest.GetRequestStream())
            {
                reqStream.Write(data, 0, data.Length);
                reqStream.Close();
            }
            #endregion

            HttpWebResponse resp = (HttpWebResponse)wRequest.GetResponse();
            Stream stream = resp.GetResponseStream();
            ////获取响应内容
            //using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
            //{
            //    strResult = reader.ReadToEnd();
            //}

            Image img = Image.FromStream(stream);
}
Img = Image Image.FromStream (stream); newspaper "Stream.Length" threw an exception reason "System.NotSupportedException" stream type is not a valid image, the result can be output to see if the callback correctly
/// / fetch response content 
            // the using (= the StreamReader new new Reader the StreamReader (Stream, Encoding.UTF8))
             // {
             //     strResult reader.ReadToEnd = ();
             // }

Check the result accurately.

 Generate applet code (errcode: 41030) invalid page hint 
this method to generate two-dimensional code must be posted applet page, otherwise can not obtain an applet code

Guess you like

Origin www.cnblogs.com/wuchaofan1993/p/12566701.html