|
Rank: Advanced Member Groups: Member
Joined: 12/5/2007 Posts: 57
|
Hi,
On one of our servers despite what we try we cannot seem to be able to reliably change the amount of time until a users session times out. Previuosly I had added a timer control to each page and once 15 minutes had elapsed the an event would fire and my handler would update a session variable. I had hoped this would work but it does not and the user's session times out after 20 minutes.
So I am thinking I need to find a way to very subtly update something on the pages or whatever in order to prevent the session from timing out. I was thinking I could use a callback control to do this. Any ideas as to how I could make something like that work? Ideally I would prefer not to have any of the page refreshed if I can avoid it but will do so if there is no other way around it.
Thanks
Gary
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, If you use a master page, you can place a CallbackPanel inside the master page and then use a timer to trigger the CallbackPanel. You can put the whole CallbackPanel inside a hidden DIV so that it is not visible. You will need to use something like this to trigger the CallbackPanel:
Code: JavaScript
function startCalbackTimer()
{
setTimeout(function()
{
eo_Callback('<%=CallbackPanel1.ClientID>');
}, time_out_value_in_ms);
}
That should trigger the CallbackPanel once. In order to trigger the CallbackPanel again, you can set the CallbackPanel's ClientSideAfterUpdate to the same function (something like ClientSideAfterUpdate="startCalbackTimer"). That way once the CallbackPanel is done, it calls startCalbackTimer again and triggers the next call after the time out. Please let us know if this works for you and feel free to let us know if you have any more questions. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/5/2007 Posts: 57
|
Hi, Im not quite sure of what you are suggesting here. As the it is .net 1.1x project unfortunately I dont have the luxury of using a master page and will have to put this on each of my pages.
Is there no way to avoid using javascript? Perhaps I will look at some of the sample code and see if I get some ideas there that may work for me.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
If you do not have master page, then yes, you will have to put this inside every page. You probably will want to put everything inside a user control and then include the user control in every page. This will be very similar to the way you put your timer control inside every page.
There is no way for you to avoid JavaScript here. It is needed for the solution to work. I am not exactly sure why this will be a problem though. Most ASP.NET pages will not work without JavaScript (many standard controls such as LinkButton requires JavaScript to work). All our controls need JavaScript to work. So if user doesn't have JavaScript enabled, then nothing will work anyway.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/5/2007 Posts: 57
|
Sorry for being such a dumb a**. So I think I am starting to understand a little bit. I am thinking I will create a user control to display the length of time the user has been logged in. Presumably inside the handler for the callbackpanel is where I put the code to update the session time in my control.
Where I am still confused is this, when my timer elapsed event fires what do I call in order to make things work? Am I supposed to call the javascript function? Sorry for sounding so clueless but I really dont understand how this works. Or do I set a trigger in the callbackpanel for the timer control?
Thanks
Gary
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You don't really need a separate timer or handle the elapsed event. The code we provided already does that. You will need to put the JavaScript function in your user control and then call startCalbackTimer once. The full code will be like this:
Code: JavaScript
function startCalbackTimer()
{
setTimeout(function()
{
eo_Callback('<%=CallbackPanel1.ClientID>');
}, time_out_value_in_ms);
}
//Start the timer
startCalbackTimer();
Code: HTML/ASPX
<eo:CallbackPanel
ID="CallbackPanel1" runat="server"
ClientSideAfterUpdate="startCalbackTimer" ....>
.....
</eo:CallbackPanel>
Once it starts, it will keep repeating making callbacks to the server and you can update your Session variables inside the CallbackPanel's Execute event. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/5/2007 Posts: 57
|
Thanks for your patience and help, it is greatly appreciated. So I put the javascript code into my user control. The call to the function, where do I put it? Is that from within my vb code in the page load event handler or is it as shown?
The other thing is how do I control the amount of time between the calls? Without a time control I have no idea where I would set this.
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Just put the code in as shown. As to the amount of time between the calls, you need to change "time_out_value_in_ms" in our code to an actual number that represents the amount of time in millisecond. For example, if you want the call to happen every 10 seconds, then put 10000 there.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 12/5/2007 Posts: 57
|
Thanks, I will give it a try and let you know how I make out.
|
|
Rank: Advanced Member Groups: Member
Joined: 12/5/2007 Posts: 57
|
Well i did as you suggested but as soon as the page containing the user control loads I get the following error:
Server Error in '/TrueContact' Application.
Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The server block is not well formed.
Source Error:
Line 6: setTimeout(function() Line 7: { Line 8: eo_Callback('<%=CallbackPanel1.ClientID>'); Line 9: }, 10000); Line 10: }
Source File: c:\inetpub\wwwroot\TrueContact\SessTime.ascx Line: 8
Version Information: Microsoft .NET Framework Version:1.1.4322.2443; ASP.NET Version:1.1.4322.2443
Any idea what I am doing wrong?
Thanks
Gary
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Sorry, the following line:
eo_Callback('<%=CallbackPanel1.ClientID>');
Should be:
eo_Callback('<%=CallbackPanel1.ClientID%>');
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 12/5/2007 Posts: 57
|
Hi,
That worked and the user control works well also. Thanks so much for all your help!
|
|