Questions › ASP.NET AJAX for window CE IE 7 - out of memory exception

Working on one application to display Image from different directory such 'C:\Core\Gate1\Gate1.jpg' using ajax timer and refreshing the page to display newly updated image. It is working for 4 to 5 hours then it throwing out of memory error.

The web page access through window CE 6.5 and IE 7 on the device.

I suspect it is problem with the window CE browser, but there is no other way to read images from different directory.

JavaScript won't allow it because it is security threat.

Is there anything I could do to fix this issue. Any suggestion much appreciated.

Here is my update panel:

  <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>

timer tick code:

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
    {
    }
}

Updated: Image.aspx code:

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
    {
    }
}
Comments :
Adam Heeg replied

Is it possible all the images are being stored in the viewstate or session? Maybe if you clear that out each time you'll avoid the problem.

It is working for 4 to 5 hours then it throwing out of memory error. Who is throwing this exception? The client's browser, or the server? Can you please add the stacktrace and text of the exception to the question?

dawncode replied

client browser throwing this error

@dawncode which one?

@dawncode Working on one application to display Image from different directory such 'C:\Core\Gate1\Gate1.jpg' So, you are displaying the client's local data - the images are not hosted on the server?


0 Answers :