日期:2014-05-20  浏览次数:20876 次

Image动态读取图片问题
主要是在一个柱状图统计页面,根据不同的条件绘出图像并保存在statistics_fh_Column.jpg中,然后将页面上的Image1的ImageUrl指向该文件,部分代码如下
System.IO.MemoryStream ms = new System.IO.MemoryStream();

Response.ContentType = "image/Gif";

image.Save(Server.MapPath("../statistics/pics_zxt/"+@"statistics_fh_Column.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
Image1.ImageUrl="../statistics/pics_zxt/statistics_fh_Column.jpg";

出现的问题是:我第一次选择统计条件绘图显示没问题,但是再更改条件显示的永远是第一次统计的页面,我看了下statistics_fh_Column.jpg图片,该图片已经更新了,但是前台却没有显示,急需指教!!!!

------解决方案--------------------
图片后面加上随机数。。
Random rnd = new Random();
int i = rnd.nex();

url+i

------解决方案--------------------
缓存了,同意楼上的解决办法,url后面加个随机数

Random rnd = new Random();
int i = rnd.nex();

....
Image1.ImageUrl="../statistics/pics_zxt/statistics_fh_Column.jpg?" + i.ToString() ;