.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

Keep session alive by using timer control

Posted By:      Posted Date: October 20, 2010    Points: 0   Category :ASP.Net
 

Hi!

 To avoid that users get logged out when they haven't been active for a while, I am using a Timer-control to make a request periodically before the session times out.

My problem is that even though it is not shown (which is good), the entire page gets sent back to the client on each "tick" (25k or so, shown in Fiddler) and even if this is not really a problem, it would make me feel a lot better
if less data was returned (since I am really not doing anything anyway). I am using this code in my masterpage which all of my pages use.

I guess this should be easy to solve if I only had some more Atlas knowledge...
What am I doing wrong?

Grateful for any help,
Markus

---------------------------------------------------------------------------

Code on the client side:

<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true&


View Complete Post


More Related Resource Links

Accessing Session State in a User Control

  
We have a web site that implements a custom SiteMapProvider using a User Control added in the master page. I need to be able to limit the sitemap nodes added depending on the logged in user, that is, certain users should not see certain sitemap nodes. Currently, the login processing code determines if users are in the certain category or role and then sets a value in session state, for example, Session["UserInRoleXXX"] = "Yes"; I tried changing the code in the user control to check the session state, but I got the following error: NullReferenceException ... Object reference not set to an instance of an object." Can session state be accessed in a user control? If so, how? If not, any suggested solutions? Thanks in advance for any help.

Why ASP.Net AJAX Timer control stops ticking when we right click on the page?

  
Asp.Net AJAX Timer control stops ticking when I right click on the page. Actually i am updating a label using timer control for every second. When I right click on the page the label is not getting updated. I mean the timer stops ticking. Please tell me what is actually happening and how can i resolve it.

WCF using ASP .NET Session and Timer object

  
I've got a WCF service that handles account management for a Silverlight 4 application. It uses PerSession as the InstanceContextMode and Required as the AspNetCompatibilityRequirementsMode so I can use ASP .NET SessionState (Silverlight only supports BasicHttpBinding, which doesn't support WCF sessions). When the client application calls the Login method, the service sets up a System.Timers.Timer object that fires after five minutes. The client calls a KeepAlive method every thirty seconds to let the service know its still alive, KeepAlive resets the timer. The idea is if the user leaves by closing the browser or leaving the page without properly logging out, after five minutes the timer event fires and it's supposed to set some flags in the application's database. This mostly works. The problem is that HttpContext.Current.Session is always null within the timer event. It works fine within the other methods. Since I can't access session, I can't figure out which user it is to perform cleanup. Can I access the Session object? Is there a better way for me to maintain session state while keeping Silverlight compatibility?

page inside update panel doesn't refresh the session object after postback of any control

  

Hi,

I have many controls like dropdown, radiobuttonlist, etc on my page and I put all these controls inside the update panel so that the page doesn't look to be posting back when something is selected. Now the working on the page is very smooth. But the session object isn't getting refreshed even if I postback to the server and as a result even if the users are working on the page they are being sent to the login screen after 20 mins.

Is there anyway where I could put all the controls in update panel and still refresh the session after any postback(dropdown selection)

Any help is greatly appreciated.

Thanks in advance


Network Stream and Timer Control

  

Hi all,

Please help me out here.... it has been a while that i have been looking around on the web for this and to no avail....

I basically have a network stream that i need to read on regular intervals in ASP.NET. The scenario is a chat application and i need to constantly check the network stream whether data has been pushed to it.

I tried ASP.NET AJAX TIMER CONTROL to read the network stream on Tick event (3 seconds interval). My aspx source looks like this:


 <asp:UpdatePanel runat="server" ID="updatepanel1" UpdateMode="Conditional">
       <Triggers>
       <asp:AsyncPostBackTrigger ControlID="timer1" />

       </Triggers>
       <ContentTemplate>
       <asp:TextBox runat="server" TextMode="MultiLine" Rows="30" Columns="100" ID="textbox1"></asp:TextBox>
       </ContentTemplate>
       </asp:UpdatePanel>
      


In The Timer1_Tick event I have code to read the network stream.

However, I dont get any results in the textbox. I know data is being sent and received fine (i checked that using various techniques) so no problem there. The only problem is to CONTINUE TO READ THE NETWORK STREAM AT REGULAR INTERVALS and i cant figure out how that

ReportViewer looping ajax calls to keep session alive causes Firefox to look like it's constantly r

  
In the HTML generated by the ReportViewer there is the following line of code (I've tried ot make it more readable by removing the superfluous information)
setTimeout("frames['ReportViewer1TouchSession0'].location.replace('/Reserved.ReportViewerWebControl.axd?...&TimerMethod=KeepAliveMethodReportViewer1TouchSession0...", 0);

function KeepAliveMethodReportViewer1TouchSession0() {
   setTimeout("frames['ReportViewer1TouchSession0'].location.replace('/Reserved.ReportViewerWebControl.axd?...TimerMethod=KeepAliveMethodReportViewer1TouchSession0....", -1703027296);
}

 

When the Reserved.ReportViewerWebControl.axd is called it makes a GET request that returns the following HTML:

 

<html><body><script type="text/javascript">parent.KeepAliveMethodReportViewer1TouchSession0();</script
></body></html>
 

 So in effect it becomes a recursive function and because KeepAliveMethodReportViewer1TouchSession0 calls a set timeout with a negative timeout value, in Firefox it's called immediately, in about 10 secon

Label + Timer Control + Background color

  

Hi All,

            When my user sign in I want to show one Label control having Background color 'Green' for next 2 min's. After 2 min's it should become yellow and after 5 min's it should become red.

            I wrote sample prog for it. But I am not getting th proper output. Please help me for this.

Design:

<form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:Timer runat="server" id="UpdateTimer" interval="5000" ontick="UpdateTimer_Tick" />
        <asp:UpdatePanel runat="server" id="TimedPanel" updatemode="Conditional">
            <Triggers>
                <asp:AsyncPostBackTrigger controlid="UpdateTimer" eventname="Tick" />
            </Triggers>
            <ContentTemplate>
                <asp:Label runat="server" id="DateStampLabel" 
                    style="font-size: x-large; font-weight: 700" />
            </ContentTemplate>
        </asp:UpdateP

Timer control issues...page gets slower and slower....

  

 Hi all,

I have a Update panel with a Timer control inside the <ContentTemplate> so the JavaScript timing component is re-created only when each postback finishes. I am testing with static data in a small table. I query this table every 3 seconds. It works great for the first 5 min but then it starts to take longer to retrieve the data.... (I can see that with a time stamp I post back in a Label control).

I am not sure why that is happening. I thought that was because I had the Timer control outside the UpdatePanel (as I was using a Trigger) but I moved that inside the UpdatePanel but still get the same results.

What could be happening here?

Thank you

 


How do I set the Interval for a Timer control which is inside a Update control?

  

Hi all,

Basically I am trying to execute this code:

        <ContentTemplate>      
        
         <asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Enabled="True" Interval=Convert.ToInt32(ViewState["RefreshInterval"] />  
...

ERROR:

Error 1 Cannot create an object of type 'System.Int32' from its string representation 'Convert.ToInt32(ViewState["RefreshInterval"])' for the 'Interval' property.

Thank you



 


Flickering Problem while using a Ajax Timer Control to refresh a chart control in asp.net2010

  
Hi Everybody ,  

I am facing a flickering issue when i am trying to refresh a chart control on the tick of a timer .I am listing

below the code of my application ,Please help me remove this problem so that chart control get refreshed without any flickers on the specified time interval

Thanks in advance.

 C# code:

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            MyLabel.Text = System.DateTime.Now.ToString();
            Txt1.Text = "Mohit";
           
        }
        BindData();
     

    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {

        Label1.Text = "Grid Refreshed at: " + DateTime.Now.ToLongTimeString();
    }

    public void BindData()
    {
        DateTime st = new DateTime(2010, 6, 1);
        int dys = 12;
        Dictionary<DateTime, long> dict = GetData(st, dys);

        foreach (DateTime d in dict.Keys)
        {
            string xlab = d.ToString("M/d");

            DayOfWeek wd = d.DayOfWeek;
            if (wd == DayOfWeek.Sunday || wd == DayOfWeek.Saturday)
            {
                Chart1.Series["weekends"].Points.AddXY(xlab, dict[d]);
         

application pool recycle fails when any session alive with claims sharepoint 2010

  

Hi, 

I'm having once interesting (or annoying probably) in my SharePoint environment.

To give you the context of my environment. 

I've SharePoint 2010 Farm. 

One web application configured as claims (with extended web set to internet zone)

Extended web is enabled to have custom membership provider - that is integrated with CRM system (so, i don't have default sql membership database schema and it's also without any roles provider).

Now, this webapplication is running under one application pool (ofcourse), that's schedule to recycle every night. 

Now, in order to simulate this issues that i'm having. I'm reseting this recycle issue. Rescheduling this causes application pool to recycle (default behavior - it goes well). But when scheduled recycle occurs, i'm getting many errors in event log and IIS logs).

 

Event Log (2 errors): 

Application Error: Event ID: 1000 (100)

Faulting application name: w3wp.exe, version: 7.5.7600.16385, time stamp: 0x4a5bd0eb

Faulting module name: KERNELBASE.dll, version: 6.1.7600.16385, time stamp: 0x4a5bdfe0

Exception code: 0xe053534f

Fault offset: 0x000000000000aa7d

Faulting process id: 0x%9

Faulting application start time: 0x%10

Faulting application path: %11

Faulting module p

how to set session timeout period for a particular control

  

hello sir.

            in my application the default time out period for a session is 20 minutes. but i want to increase the sessiion time out period for a textbox.

how can i do this. plz any body tel me.

          thanking you.


ReportViewer looping ajax calls to keep session alive causes Firefox to look like it's constantly r

  
In the HTML generated by the ReportViewer there is the following line of code (I've tried ot make it more readable by removing the superfluous information)
setTimeout("frames['ReportViewer1TouchSession0'].location.replace('/Reserved.ReportViewerWebControl.axd?...&TimerMethod=KeepAliveMethodReportViewer1TouchSession0...", 0);

function KeepAliveMethodReportViewer1TouchSession0() {
   setTimeout("frames['ReportViewer1TouchSession0'].location.replace('/Reserved.ReportViewerWebControl.axd?...TimerMethod=KeepAliveMethodReportViewer1TouchSession0....", -1703027296);
}

 

When the Reserved.ReportViewerWebControl.axd is called it makes a GET request that returns the following HTML:

 

<html><body><script type="text/javascript">parent.KeepAliveMethodReportViewer1TouchSession0();</script
></body></html>
 

 So in effect it becomes a recursive function and because KeepAliveMethodReportViewer1TouchSession0 calls a set timeout with a negative timeout value, in Firefox it's called immediately, in about 10 seconds Firebug logs over 150 GET requests in one minute there

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

  
In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

MS SQL Server: Disconnect Users From Database - Kill User Session

  
If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.

Accessing the different controls inside a GridView control

  
how we can access a particular control which resides inside a GridView control. In this article I will show you how you can access different controls inside a GridView control. We will see how we can access a TextBox control, a DropDownList control and a ListBox control. If you are working with ASP.NET 1.X then you might want to check out my article Accessing Different Controls Inside a DataGrid.

In-Depth look at the GridView Control

  
In the last article we looked at few of the new controls available in Asp.net 2.0. We also talked about Grid View Control which has replaced the Asp.net 1.1 DataGrid control for good. In this article we will examine more features of the Grid View control. In this article we will see some of the common operations that can be performed using the GridView control. Apart from these operations there are many more functions that can be performed on the control and which we will see in the later articles
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend