I have a problem about session in my ASP.NET Web App. When i write my username and password and clicked login button, session is abandoned.
In my web.config, i use :
sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20"
Can anyone help me ?
You shouldn't use stateConnectionString and sqlConnectionString attributes if you are going to store session in asp.net process.
Just write sessionState mode="InProc".
http://msdn.microsoft.com/en-us/library/h6bb9cz9%28v=vs.71%29.aspx
Related
An application I'm working on relies on sessionState for timeout, but there is a need to have custom banners on the login that need to occur after the timeout occurs. Is there a way to pass values or variables to the login page after a timeout?
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="60" />
I have checked various questions asked in SO in this topic also tried the solutions provided for the various questions, but it doesnt work for me.
My application is ASP .Net4.5, I store username, usertype in session and later it is used while inserting data to the SQL tables. I have set the session time out in webconfig as follows.
<system.web>
<authentication mode="Forms">
<forms loginUrl="Login.aspx" name=".mycookie" timeout="60"></forms>
</authentication>
<sessionState mode="InProc" cookieless="false" timeout="60" />
In the IIS settings against Sessionstate the following were set
SessionState = In Process
Cookie settings -> Mode = Use Cookies
Name = ASP.Net_SessionId
Timeout (min) = 60
I'm not sure whether I'm setting this in wrong way in the above settings. The issue is my application session timeouts much before the set time, I feel it gets timeout in 10-15 minutes. Please advise how to set the timeout value correctly.
Probably, you are getting problem with form authentication timeout and session timeout. Please see here.
Try this in web config file.
<system.web>
<authentication mode="Forms">
<forms timeout="50"/>
</authentication>
<sessionState timeout="60" />
</system.web>
I tried setting session timeout, but it didnt worked for me. I decided to store those session variables used in cookies, and read from cookies. Now there is no session timeout issue. I clear the cookies while login to the application, also set the expiry to 1 day to avoid any issue. Thanks for helping me.
I am little bit confused... I have the following in my web.config and i am still getting error message. This error only happens when i am logged in since the user info is in the session. In not logged in mode, i just get empty user.
Error:
Session state can only be used when enableSessionState is set to true,
either in a configuration file or in the Page directive. Please also
make sure that System.Web.SessionStateModule or a custom session state
module is included in the <configuration>\<system.web>\<httpModules>
section in the application configuration.
Web.config:
<sessionState mode="SQLServer" allowCustomSqlDatabase="true" sqlConnectionString="data source=MyServer;Initial Catalog=MyDatabase;user id=user;password=password" cookieless="false" timeout="20" />
What am i missing here?
I have it set to 120 minutes but it doesn't last that long. I am not sure exactly how long it does last but I know it isn't 2 hrs.
<sessionState timeout="120" />
This was set only in the default Web.config and NOT in the one in the Views directory nor the Web.Debug.config or Web.Release.config.
Would that make a difference as the default session timeout is 20 min?
To guarantee your sessions don't get killed by a w3wp.exe crash or an application pool recycle, you should move the session state to a separate store. The easiest is the ASP.Net State Server service. Make sure to start the service on the host machine and add this to your web.config instead:
<sessionState mode="StateServer"
stateConnectionString="tcpip=SampleStateServer:42424"
cookieless="false"
timeout="120"/>
I think you should define the session state mode
There are there different session states in ASP.NET
http://msdn.microsoft.com/en-us/library/ms178586(v=VS.80).aspx
In-Process Mode
The defaul one is <sessionState mode="InProc" timeout="10" />, the session will be clear after rebuild the project
State Server Mode
we can use this, but remember to turn the services - ASP.NET State Service
<sessionState mode="StateServer"
stateConnectionString="tcpip=localhost:42424"
sqlConnectionString="data source=.\SQLEXPRESS; User ID=sa;Password=12345678; Integrated Security=SSPI"
cookieless="false"
timeout="2"
/>
SQL Server Mode we can use this after create a DB ASPSate by command, pls check this site for details - http://www.brianstevenson.com/blog/aspstate-concurrently-running-for-net-1011-and-net-20
<sessionState mode="SQLServer"
stateConnectionString="tcpip=localhost:63586"
sqlConnectionString="data source=.\SQLEXPRESS; User ID=sa;Password=12345678; Integrated Security=SSPI"
cookieless="false"
timeout="2"
/>
The session in State Server Mode & SQL Server Mode will not be cleared after rebuild the project, it's good for development
We are developing a web application in Asp.net(4.0). In this application we use jquery and javascript and webservices and I frames
Here I am getting the problem with session expire. How can I solve this? I can't understand where the session is expiring.
If I'm understanding the question properly, you can adjust session timeout in your Web.config file, using something like this:
<system.web>
<sessionState mode="[Off|InProc|StateServer|SQLServer|Custom]" timeout="[numberOfMinutes]" />
...
</system.web>
Your use of JQuery, javascript, webservices, and IFrames are not affecting your session expiration issue.
The following page is an excellent resource for learning to use the Session State:
ASP.NET Session State Overview
Go to the section on that page titled Configuring Session State for information pertaining specifically to your question.
Here's your options for Session State configuration, including timeout:
<sessionState mode="SQLServer"
cookieless="true "
regenerateExpiredSessionId="true "
timeout="30"
sqlConnectionString="Data Source=MySqlServer;Integrated Security=SSPI;"
stateNetworkTimeout="30"/>