使用ajax计时器处理一个应用程序以显示来自不同目录的图像,例如'C:\ Core \ Gate1 \ Gate1.jpg'并刷新页面以显示新更新的图像。 它工作4到5个小时然后丢失内存错误。
通过设备上的CE 6.5和IE 7窗口访问网页。
我怀疑它是窗口CE浏览器的问题,但是没有其他方法可以从不同的目录中读取图像。
JavaScript不会允许它,因为它是安全威胁。
我有什么办法可以解决这个问题。任何建议都非常感激。
以下是我的更新小组:
<asp:UpdatePanel ID="updatepanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer ID="ImageTimer" Enabled="true" Interval="100" runat="server" OnTick="timer1_Tick">
</asp:Timer>
<div>
<asp:Image ID="image1" runat="server" Height="120px" Width="100px" />
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ImageTimer" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
计时器刻度代码:
protected void timer1_Tick(object sender, EventArgs e)
{
try
{
String gateName = ddlGate.SelectedItem.ToString();
string path = IMAGELOC + gateName + "\\" + gateName + ".jpg";
string actualCardId = string.Empty;
GateManager.GateData gateData = new GateManager.GateData();
gateData = GateManager.GetGateData(gateName);
actualCardId = gateData.CardId;
lblName.Text = gateData.FirstName + " " + gateData.LastName;
lblExp.Text = gateData.Exp;
if (actualCardId != "NOTFOUND" && actualCardId != "INVALID"
&& actualCardId != "" && !string.IsNullOrEmpty(actualCardId))
{
image1.ImageUrl = "Image.aspx?path=" + path + "&CardId=" + actualCardId;
}
else if (actualCardId == "NOTFOUND")
{
//GET IMAGE FROM DIR
image1.ImageUrl = "Images/ImageNotFound.jpg";
}
else if (actualCardId == "" || actualCardId == null)
{
image1.ImageUrl = "Images/ImageNotFound.jpg";
}
else if (actualCardId == "INVALID")
{
//GET IMAGE FROM DIR
image1.ImageUrl = "Images/invalidcard.jpg";
}
}
catch
{
}
}
更新: Image.aspx代码:
protected void Page_Load(object sender, EventArgs e)
{
try
{
Response.ContentType = "image/jpeg"; // for JPEG file
string physicalFileName = Request.QueryString["path"];
Response.WriteFile(physicalFileName);
}
catch
{
}
}