Thursday, 2 August 2012

Avoid HOST Timeout/For Session Alive.

Hello guys, most of the ASP.NET hostings Kills the Session If user doesn't interact with Server Like GoDaddy.com does it.
also see this Post : http://forums.asp.net/p/1829462/5091859.aspx Question asked by a User.


Method #1: We can use XMLHttpRequest to interact with server.
<script type="text/javascript">
    function ResetTimeOut() {
        var pageToCall = "KeepSessionAlive.aspx";

        if (window.XMLHttpRequest) {
            request = new XMLHttpRequest()
        }
        else {
            request = new ActiveXObject("Microsoft.XMLHTTP")
        }
        request.open("POST", pageToCall, true);
        request.send("");
    }
window.setInterval("ResetTimeOut();",600000);
</script>
Method #2: We can use timer control with update panel to send requests to server.
<asp:ScriptManager ID="ScriptManager1" runat="server"/>
</asp:ScriptManager>
 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="600000"/>
</ContentTemplate>
</asp:UpdatePanel>
These methods doesn't need any use interaction or the page to refresh.

Good Luck` hope this trick will work :-) and we can win against the hosting providers.. 

1 comments:

Mahad Bin Mukhtar said...

Check : http://forums.asp.net/p/1831844/5100449.aspx/1?Re+Timeout+problem+

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More