I have this class in my infrastructure that suppose to return random image. It always returns same image. I have exactly same code used in different place on my website and it works. Any ideas?
This question is where I got the info for getting random value. I don't understand why it works on one place and not another though...
Background.cs
public static class Background
{
public static string Get()
{
photoBlogModelDataContext _db = new photoBlogModelDataContext();
var image = _db.Images.OrderBy(x => Guid.NewGuid()).FirstOrDefault();
return image.Small; // Always same value?
}
}
Same code on another page that works where I loop through my gallery and choose random image from it
<img src="@Url.Content("~/content/uploads/" + item.Images.OrderBy(x => Guid.NewGuid()).FirstOrDefault().Small)" alt="" />