Force an image to load from server (PHP or ASP.NET)
I ran across a need to make sure an image on a webpage loaded from the server on each load of the page. This was accomplished by loading the images with a random number as a parameter.
So it ended up looking like: <img src=”http://www.website.com/images/1.png?rndNum=2204>
In PHP this was done by adding: ?<?php echo rand(1000,7000)?> to the image source.
In asp.net (VB): Using an asp:image with id =”Image1″ on the page.
VB code behind:
If Not Me.IsPostBack Then
Dim randImgNum As Integer
randImgNum = RandomNumber(1000,7000)
Me.Image1.ImageUrl = “http://www.website.com/1.png?rndNum=” & randImgNun