I have a simple access control class which allows to check a user has permissions, this then interacts with the static variable:

private static bool canUpdate = false;

This is used during the page load protected void Page_Load(object sender, EventArgs e)

{
    if (!Page.IsPostBack)
    {
        AccessControl I = new AccessControl(parameter);

        canUpdate = I.HaveEdit;
    }
    BindGrid();
}

This all works just fine, it is simple and the bool is used as part of another method (called as a gridview code expression) in order to conditionally display a control in a row. This also works just great.

However I am in a testing stage and I have realised that under normal operations everything is great, however after a time has passed (significant, like half hour or so), the buttons are no longer displayed (in other words the canUpdate has set to false).

The code for the display:

protected bool ShowNewStamps(object date)
{
    //Returns to Bind Expression whether to display Timestamp Link
    if (date == null & canUpdate == true)
        return true;
    else
        return false;
}

The date is passed in as a binding expression, passing in the date of the cell before, therefore I know this is not the issue.

The issue only presents itself when the page is refreshed after significant time, is this due to static variables having a lifetime and i am only setting the variable on first page load?

Related posts

Recent Viewed