1

I have been working on a way to dynamically change the image src on a webpage. I'm using ASP.NET MVC3 and have an image point to a controller action. This works great for first load. Then I have an upload control and refresh the img src via jquery to load the new image. I call the same controller action as before in the first load.

This work in all browsers except for IE. In IE when I change the image and load via jQuery, I get prompted to download the file.

How can I refresh the image and have my required functionality work in IE?

Thanks!

~ Steve

View:

 <img src="@Url.Action("ShowSavedImage", "DisplaySettings")" id="imgLogo" class="ContrainImage" />

Controller:

 public ActionResult ShowCachedImage()
  {        
    return File(user.TempLogoBytes, user.TempLogoContentType);            
  }

JavaScript:

 $('#imgLogo').attr('src', '@Url.Content("DisplaySettings/ShowCachedImage/?v=")' + new Date().getTime());
4

1 回答 1

2

我发现问题根本不是 img src 刷新。我有一个控制器操作来处理图像保存异步(来自 kendoui 上传控件),它返回一个 JSON 结果,这就是浏览器中弹出的内容。我删除了它,一切正常。

于 2012-08-29T17:30:52.870 回答