1

I have a webpage where I want the typed in data to auto save. For that I use the ASP.NET timer. But my problem is I still want my session yo timeout due to inactivity, so can i make the timer call the tick without refreshing the session time?

Here is the code, sorry but i could no upload picture yet :=

<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>


<asp:Timer ID="SaveTimer" runat="server" Interval="150000"
    ontick="SaveTimer_Tick">
</asp:Timer>
<asp:UpdatePanel runat="server"  updatemode="Conditional">
    <Triggers>
        <asp:AsyncPostBackTrigger controlid="SaveTimer"
            eventname="Tick"  />
    </Triggers>
    <ContentTemplate>
    </ContentTemplate>
</asp:UpdatePanel>
2
  • 1
    The session timeout is integrated deeply into the ASP.NET pipeline. There is no easy way of doing this. Commented Jun 28, 2012 at 9:17
  • So its not possible to use timer without refreshing the Session ? For security reason i need session to timeout. Commented Jun 28, 2012 at 9:22

4 Answers 4

1

What I think you want is to keep the session alive as long as the user is working on that page. When you don't trigger the auto save option, when there are no changes, you won't go back to the server and thus not update the session. In that case, the session will time out eventually when the user stops working on that page.

So again, only call back to the server when there are actually changes to be saved.

Sign up to request clarification or add additional context in comments.

Comments

0

No. There is no way asp.net will be able to detect your user is inactive. So long as your browser is making requests, for the server user is active.

You will have to track inactivity yourself using javascript, and post to a logout url when the user is inactive say for 10 minutes.

You can detect if the user is active my tracking blurs on input, button clicks, and mouse activity. Set a javascript variable to indicate that the user is infact there.

Comments

0

The only way to do that, to make an auto save with out affecting the session, is if you do it with a page that have EnableSessionState="false", or a handler with out session.

In that case you must pass some parameters encoded with from the url so the handler (or the page with out session) knows where to save the data in the database (and not on session)

Comments

0

I did something similar by doing this:

Response.Cookies.Remove(FormsAuthentication.FormsCookieName);

It doesn't exactly stop the session from timing out, but by not updating the cookie at the client it would eventually forget which session it was using. Now if you're not using forms authentication i suppose you would have to remove some other cookie though.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.