我將圖像存儲在數據庫中,我使用圖像處理程序使用文件路徑+ ID顯示圖像。我遇到的問題是當我通過頁面更新圖像時,圖像不會改變。奇怪的是我沒有這個問題與Firefox或鉻。ASHX圖像處理程序不在ie中工作,在Firefox和Chrome中工作
ASHX處理程序
public void ProcessRequest(HttpContext context)
{
Guid image_id;
if (context.Request.QueryString["id"] != null)
image_id = System.Guid.Parse(context.Request.QueryString["id"]);
else
throw new ArgumentException("No parameter specified");
context.Response.ContentType = "image/jpeg";
Stream strm = GetImageFromDatabase(image_id);
if (strm != null)
{
byte[] buffer = new byte[4096];
int byteSeq = strm.Read(buffer, 0, 4096);
while (byteSeq > 0)
{
context.Response.OutputStream.Write(buffer, 0, byteSeq);
byteSeq = strm.Read(buffer, 0, 4096);
}
//context.Response.BinaryWrite(buffer);
}
}
用戶控制代碼
string imagePath = "<a href=" + (Image.ImageUrl = "~/ShowImage.ashx?id=" + r["Image_id"]);
標記
<asp:UpdatePanel ID="Upd1" runat="server" UpdateMode="Always" >
<ContentTemplate>
<div id="mpe" style="width: 600px; padding: 5px;">
<uc2:IMG ID="IMG1" cssclass="bodycopy" runat="server" />
</div>
<asp:UpdateProgress ID="upp1" runat="server" AssociatedUpdatePanelID="Upd1">
<ProgressTemplate>
<div id="progressBackgroundFilter">
</div>
<div id="modalPopup">
Loading...
<img align="middle" src="../images/Ajax/loading_1.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:UpdatePanel>
我不知道張貼什麼其他的代碼,但這裏是我認爲是相關的。當我點擊我的按鈕更新圖像時,它會成功更新數據庫中的行。此外,我可以更新有關圖像的數據並正確更新。
任何想法?
你可以覈對一下頁面** ** IE使用**開發工具**,檢查圖像是否存在或不?? – 2012-04-17 13:45:02
圖像顯示在ie頁面加載時,當我更新圖像時,我看到舊圖像,而不是新圖像,如果有意義的話? – 2012-04-17 13:47:52
這可能是由於緩存..請看看這個** http://superuser.com/questions/81182/how-to-force-internet-explorer-ie-to-really-reload-the-page* * – 2012-04-17 13:49:38