Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

problem with leaving my site for a while

when i leave my site for minutes and then come back and click on a submit button it only reloads the page for the first time and in the second time it works correctly, any one knows what is happening with my site??

user-image
Question added by marwa khalaf , .Net Developer , Sands National Academy
Date Posted: 2013/05/14
Muhammed Effat Ahmed Afifi
by Muhammed Effat Ahmed Afifi , Project Leader [Microsoft Business Unit] , Wipro Arabia Limited

At first i will consider that your site already was built using asp.net because my answer will be related to the .net technology.
So let me first highlight for you some basic definitions that will clarify for you why this happen?? HTTP is a stateless request/response protocol.
Every asp.net page has objects and each object in this page has lifetime and the page itself has life cycle.
My commentary about your questions is that this happened as a result of your page contains an object /variables that have a specific lifetime for ex.
20 sec.
after the page render on the client side and after the object lifetime is ended in this case the page should reload/posted-back again to the server in order for updating the page variables/object.
about the solution of this you can use the technique of managing asp.net page objects lifetime also you should read more about asp.net caching this will help you more..
finally, i wish that me answer will help you..
and you can check and read more in the below link.
http://mr-ponna.com/Article/21/Understanding-Object-Lifetime/

Maher Alsilwy
by Maher Alsilwy , CONSULTANT , B7R DESIGN WWW.B7RDES.COM

I agree with Mr.
Muhammed Effat Ahmed Afifi.
It's because the lifetime of one of the element of the page.
You can use some techniques like cookies or sessions or caching as a solution for this.

Ashraf Sabry
by Ashraf Sabry , Freelancer developer , N/A

This may be caused by many issues.
Onsite diagnosis have to be done to discover the cause of the problem precisely, but here are my initial thoughts: - Does your application use the Session collection? If you leave your site idle for 20 minutes (the default lifetime of ASP.Net session state) the session will expire.
Maybe when you submit the form after the session expires, some server side code tries to access the expired session resulting in an exception.
The yellow error page should appear, but maybe your site has a global error handling policy that prevents it from appearing.
- Does your site use the Application collection? The Application collection is a global storage for the whole app domain (by default, an ASP.Net application runs under one app domain).
IIS has recycling policies for each web application.
Maybe your site is set to be recycled after certain amount of idle minutes.
When you leave your page idle, IIS recycles the application (i.e restarts it) resulting in that the Application collection is cleared.
Later when you click the button, the code behind tries to access the Application collection and an exception is thrown.
(This point holds to the Cache collection too).
- Does you site use an authentication cookie? Maybe when you leave the page idle, an authentication cookie (or any other general cookie) expires, and your button click goes in vain because the server side code requires this cookie to be set.
You may be wondering, why then everything works well after the second click? Because all the above symptoms were probably fixed on the first click.
The first click causes fresh new Session, Cache, and Application collections to be created, and the renewal of cookies.
It seems that this system was developed by others whom you can't reach.
Here's my advice to accurately diagnose the problem: - Use an HTTP analyzer to examine the HTTP request and response sent and received on the first click of the button after the idleness period.
I highly recommend Fiddler (http://fiddler2.com/).
- Before clicking on the button for the first time, attach the Visual Studio debugger to your application process, and set break points on the important stages of your page (OnInit, OnLoad,…) and the event handler of the button.
Examine how the processing flows on the server side.
- Examine your web.config file thoroughly.
Examine all the configurations and pay special attention to the sessionState and authentication sections.
Try to find the timeout values and relate them to the period of idleness after which you get the problem.
- Investigate how your web application is configured under IIS.
- In your browser ensure that JavaScript error notifications is turned on.
Maybe this problem is caused by some weird JavaScript issue.
- Examining the web server logs may be beneficial.

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.