I have an intranet page which needs to not time out (indefinitely) and I'm using JS to keep it alive that way.
But I am having one issue that happens when the user loses the connection (happens frequently due to to going in and out of wifi range) the session times out then.
How can I keep the session up/refresh it if that happens?
How about increase the session time out on web.config ?
<configuration>
<system.web>
<sessionState timeout="120"></sessionState>
</system.web>
</configuration>
http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.timeout.aspx
Other possible way is to make your database, connected with the user cookie, and use your "custom session" data that are totally connected with your users.
Try using in web config if you are using Form Authentication
<system.web>
<authentication mode="Forms">
<forms timeout="120"/>
</authentication>
<sessionState timeout="120" />
</system.web>
first Sets the session timeout on the server is for all session
Rather than a single Session
out wifi range is the entire network are broken
so not keep alive
You have to use cookie
use cookie keep alive
Related
In a project (build with Sitecore version 6.6 and ASP.net Webforms) I experience a strange session loss issue on Content Delivery (CD) server. I googled on this subject using the keywords ASP.net and session loss. I found a lot of interesting stuff, but not the solution.
In the meanwhile, I figured out that it is nearly impossible that the cause of the issue is an Application Pool recycle or the auto-bot detect function inside Sitecore.
The way we write data to the session.
System.Web.HttpContext.Current.Session["name"] = "data here";
The way we read data from a session.
string data = (string)System.Web.HttpContext.Current.Session["name"];
SessionState configuration
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;user id=sa;password=" cookieless="false" timeout="20" />
The Sitecore configuration is the default. The session loss is at random times within 5 minutes. Does anyone know a solution?
One possible reason is following setting.
<authentication mode="None">
<forms name=".ASPXAUTH" cookieless="UseCookies" timeout="180" />
</authentication>
Also look at session setting in IIS, probably there is something incorrectly setup.
I would suggest that you try setting up a session state server and see if the problem still persists.
Additionally, it is worth to ask, are you using one or multiple CD servers.
I have a ASP.Net web application in witch i want to put a timeOut (for user that dosen't do anything for too much time). My test use a 3 secondes timeOut. In the web.config :
<sessionState mode="StateServer" stateNetworkTimeout="3"></sessionState>
I get the following error as soon as i run my app:
Cannot request session state in session state server.
I can't find anything relevante for this case...
i tried to put InProc in Mode="" but it dosen't timeout anything.
Looking at this, you're trying to use a State Server and set the idle time between the web server and the state server. To properly configure the web server to use a state server, you must also configure the state server. Go to your state server and run:
systemroot\Microsoft.NET\Framework\versionNumber\aspnet_state.exe
This will install the asp.net state service. Then in the sessionState element in your web config you will need to set the stateConnectionString attibute as well.
<configuration>
<system.web>
<sessionState mode="StateServer"
stateConnectionString="tcpip=SampleStateServer:42424"
cookieless="false"
timeout="20"
stateNetworkTimeout="3"/>
</system.web>
</configuration>
You now have two "timeouts" here. The "timeout" attribute is how long the user can keep a connection to the webserver. The stateNetworkTimeout is how long the webserver to stateserver connection can be idle. The default is 10 seconds.
Hope this helps.
ref: https://msdn.microsoft.com/en-us/library/ms178586(v=vs.100).aspx
/ip
<sessionState mode="InProc" timeout="1" cookieless="false" ></sessionState>
I mistaken secondes for minutes, the Timeout value is about minutes. So i waited 1 minute for my test...
Thanks to #Devian and #Agolo.
I am facing session expiring issue in my ASP.NET Web Forms application. The session is timing out randomly. After 5 to 10 minutes(not exact time but happening randomly) there is no any explicit session. Timeout declaration elsewhere in the code. Given below are settings I have defined in Web.Config file. Any help is much appreciated
<httpRuntime maxRequestLength="350000" enableVersionHeader="false"
maxQueryStringLength="3584" executionTimeout="180000"/>
<sessionState mode="InProc" timeout="30"></sessionState>
I have a problem related to ASP.NET Membership and Forms Authentication. I have been searching the solution for this quite long (including the StackOverflow.com), but was unable to find some solution with regards to my scenario. Please help me.
I am using an ASP.NET Membership and Forms Authentication in an application, the problem is that during testing the application for around more than 30 minutes,
the following errors come:-
1) The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
2) Session does not expires, and it does not redirect to the Login page.
3) Session values are becoming null at few times.
The application is in Production as well, but the client has not reported any of the above such issues yet.
Please find below the Web.config settings:-
<sessionState timeout="30" mode="InProc">
</sessionState>
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="20">
<providers>
<clear/>
<add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="DBSQLServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" passwordFormat="Hashed" applicationName="/ApplicationPortal"/>
</providers>
</membership>
<add name="DBSQLServer" connectionString="Data Source=SERVER-NAME\SQLEXPRESS2008;Initial Catalog=DB-Name;Max Pool Size=100;Trusted_Connection=True;" providerName="System.Data.SqlClient"/>
And not to forget the section:-
<authentication mode="Forms">
<forms loginUrl="~/Login.aspx" defaultUrl="~/Login.aspx" protection="All" timeout="30">
</forms>
</authentication>
Although there were few connections which were not disposed off, but now all the connections are properly disposed off.
I found somewhere that by closing the DataReaders, this will be resolved, but since I have disposed off all the connections, so does this effect if the DataReaders
are not closed/disposed in my scenario?
I would also like to know that what possible issues are there which is causing these two errors simultaneously, and how can I fix these two issues.
There has been also inline queries used at many of the pages.
This all sounds like a poor design.
Make sure you use one connection per request and that you are disposing it in any case (finally block)
When you say session does not expire, have you waited timeout period without making any request for sure?
When your session values are cleared it actually means that session is expired or cleared because IIS worker process was recycled. Tune up worker recycling policy or set up session state in database.
When you are saying session does not redirect to login page - this is wrong. Session has nothing to do with login page. You will be redirected there if you try to reach a page that needs you to be logged in.
I am using ASP.NET 4.0 for a site I am making. It has a login that leads to some backend sites. That all works fine...
BUT...
There seems to be a logout thing in the Session cookie. Whenever I login and leave it for a few minutes it logs me out when I load the page.
Does anybody know what I can do to change this... or remove it??
you need to set your session timeout on your web.config:
<configuration>
<system.web>
<sessionState timeout="10"></sessionState>
</system.web>
</configuration>
Default value for session timeout is 20 minutes. You can change it in your webconfig as per your need.