关于SESSION不稳定的问题
validateimage = new Bitmap(70, 20, PixelFormat.Format24bppRgb);
g = Graphics.FromImage(validateimage);
g.DrawString(VNum, new Font( "Verdana ",12),new SolidBrush(Color.White),new PointF(8,0));
g.FillRectangle(new LinearGradientBrush(new Point(0,0), new Point(110,20), Color.FromArgb(0,0,0,0),Color.FromArgb(255,255,60,40)),0,0,120,30);
g.Save();
MemoryStream ms=new MemoryStream();
validateimage.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
Session[ "VNum "] = VNum;
Response.ClearContent();
Response.ContentType= "image/Jpeg ";
Response.BinaryWrite(ms.ToArray());
g.Dispose();
validateimage.Dispose();
Response.End();
验证码这段。
很郁闷。第一次总是空的。登陆要登两次才会进入。登一次就会出现SESSION未将对象引用到实例..求解决办法。谢谢了。
[解决办法]
Session调用时,先判断是不是Null
[解决办法]
你这段代码放哪里的??