开发者

Asp.net image control problem

Hi i have a problem with my image control that is when i upload an image it shows that image but when i update it, its shows old image while updates in data base i think it gets image from cache is there any technique to handle this issue kindly tell me.

Image1.ImageUrl = populatedata.ResultSet.Tables[0].Rows[0][12].ToString();
string file_ext = Path.GetFil开发者_StackOverflow社区eName(Image1.ImageUrl);
Image1.ImageUrl = "~/EmpImages/" + file_ext;


You can change the image url everytime you get it through some random generated query string.

This way the browser won't cache it.

For instance:

int randomNumber = (new Random()).Next(0, 10000);
Image1.ImageUrl = "~/EmpImages/" + file_ext + "?rand=" + randomNumber;

But if the problem only happens sporadically and image updates aren't so oftem, you can just press Ctrl+F5 on the browser and it will refresh all files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜