ASP.NET MVC Image refreshing
- by user295541
Hi,
I have an Employee object which has an image property.
Image class contains image metadata as image caption, and image file name.
If I upload a new image for an employee on async way without full post back the new image is not appeared on the page.
I use GUID to name the image file to avoid the page caching.
I do the image modifying the following way:
ctrEmployee employee = Repository.Get(PassedItemID);
if (employee.ctrImage != null)
{
string fullFileName = serverFolder + employee.ctrImage.FileName;
FileInfo TheFile = new FileInfo(fullFileName);
if (TheFile.Exists)
{
TheFile.Delete();
}
fileName = Guid.NewGuid() + ".jpg";
employee.ctrImage.FileName = fileName;
}
resizedBmp.Save(string.Format("{0}{1}", serverFolder, fileName), System.Drawing.Imaging.ImageFormat.Jpeg);
Repository.Edit<ctrEmployee>(employee);
ImageID = employee.Image.Value;
return PartialView(UserControlPaths.Thumbnail, new ThumbnailDataModel(employee.Image.Value, 150, 150));
The partial view has an image tag which gets the saved image url string which is a GUID.
Anybody has an idea what I do wrong?