I am working on an MVC site that feeds from an existing desktop application with a really horrible database, rant over ! I have image files in the local file system that are displayed for each property, some of the filenames have spaces and dont display properly.
if (imageFound != null)
{
string fileName = item.PropertyImages.Where(i => i.ImagePosition == 1).FirstOrDefault().FileName;
fileName = System.Web.HttpUtility.UrlEncode(fileName);
item.MainDisplayImage = @"images/" + item.PropertyID + "/" + fileName;
}
else
{
item.MainDisplayImage = "images/properties/lx0001/thumb/01-image.jpg";
}
The view looks like
<a href="propertydetail.html">
<img src=@item.MainDisplayImage.ToString() title="207 Joe Bloggs Avenue" alt="207 Joe Bloggs Avenue" width="210" height="150" border="0" />
</a>
It renders in the browser like images/AMPM0263/2013-09-17+11.22.42.jpg, any ideas, help would be greatly appreciated, thanks.