views:

113

answers:

3

Hello,

I have a .Net 3.5 website which uses windows authentication and expires the session using a meta tag on the prerender of my base masterpage class.

protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);
    if (Response.ContentType == "text/html")
        this.Page.Header.Controls.Add(new LiteralControl(
            String.Format("<meta http-equiv='refresh' content='{0};url={1}'>",
            SessionLengthMinutes * 60, SessionExpireDestinationUrl)));
}

This works well for pages that do full post backs. However there are a few pages in my application where the user does a lot of work that is inside of an update panel. My company's policy is a timeout of 15 minutes. Which means, after 15 minutes of working inside of an update panel page, the user gets redirected to the application splash page.

Is there a way to reset or extend the meta tag on an async postback? Or perhaps a better way to accomplish this entirely?

A: 

In the past I have used the WebMethod(EnableSession = true) attribute on the methods that respond to AJAX calls

BlackTigerX
A: 

You could use an AJAX request to keep the session alive as well. This will work as long as the user has opened your page in the browser. See http://808.dk/?code-ajax-session-keepalive

SimonW
A: 

A better way to accomplish this entirely would be to use javascript. This will prevent meta refresh related issues if your page is bookmarked.

In place of the page META REFRESH use this javascript:

<script type="text/javascript">
    var _timerID = setTimeout("window.location='splash-url'", 900000); //15 mins
</script>

When you make a request from the update panel use this javascript:

<script type="text/javascript">
    clearTimeout(_timerID);
    _timerID = setTimeout("window.location='splash-url'", 900000); //15 mins
</script>
Barry