cannot use stateserver mode other than inproc - asp.net

The most irritating problem i've come across. I have an asp.net mvc application with sessionstate mode to stateserver. On my local machine and my old server iis6 it worked but i recently changed to a new server running iis7 and now the line:
<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" timeout="20" />
doesn't do anything. Even when I set the value in the connectionstring to something that doesn't exist it is ignored and thus it's using inproc only.
All my webapps under iis have the same problem.
I've also tried sqlserver mode with the same result. it just gets ignored.
Why oh why??

There's a place in IIS where you can disable InProcess session state.
These articles should point you in the right direction:
http://technet.microsoft.com/en-us/library/cc732964%28WS.10%29.aspx
http://technet.microsoft.com/en-us/library/cc725624%28WS.10%29.aspx

Related

Session variables lost ASP.Net

I have Visual Studio Professional 2019, licensed, in a Windows Server 2019 virtual machine.
I have moved a project from my computer to the server, but when debugging, the session variables are lost between methods; in my pc they were working fine with Visual Studio Community 2019. I have tried disabling antivirus but still doesnt work.
This is the code where I save the value in the Session:
if (nombre != null)
{
Session["Usuario"] = nombre;
}
ViewBag.error = "";
return RedirectToAction("Inicio");
}
else
{
ViewBag.error = "Usuario o contraseƱa incorrectos";
return View("login");
But when checking the Session in the view, there is no ["Usuario"] array.
I execute it in debug mode, IIS Express Chrome. Dont know if it could interfere, but I
have installed in the same machine the IIS.
I have finally made it work. I tried commenting this line in my web.config
<sessionState mode="InProc" cookieless="false" timeout="2400"/>
And the variables started working again
IIS6 joins the function of application pool to recycle some useless processes. When the application pool is caused by errors in website programs or too many visits, the process will be automatically recycled to prevent the website from entering the "crash" state. At this time, The recycling of the application pool will cause the session variable to be cleared, and the session variable will disappear.
In order to solve this problem, we start the ASP.NET State Service service on the server side, and make some changes in the system's machine.config. The session state mode is now StateServer by default. If you also have a web.config configuration file in the root directory of your website, please change mode="InProc" to mode="StateServer", and the following code can prevent the loss of session variables:
<sessionState mode="InProc" cookieless="false" timeout="60"/>
Change to
<sessionState
mode="StateServer"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>

Sharing ASP.Net session between 2 websites on IIS8 does not work

I need to share asp.net session between 2 websites on same IIS.
I created a custom session db and hijacked the stored procedure to return same appID regardless of app or url.
I created a connection string for the db in web.config:
< add name="dbConnSession" connectionString="server=xx.xxx.xx.xx.;database=ASPNETSession;User Id=xxx;Password=xxx" providerName="System.Data.SqlClient" />
Then I defined session state:
< sessionState allowCustomSqlDatabase="true" cookieless="AutoDetect" mode="SQLServer" sqlCommandTimeout="10" sqlConnectionString="dbConnSession" timeout="120" sqlConnectionRetryInterval="2" />
I developed the sites on my Win7 machine with IIS7 and login system works perfectly. I can login from 1 site, go to other site and stay logged in.
I moved 2 sites into the web server (windows 2012 with IIS8.5) and the shared session does not work. Sites simply does not share the session. I set a session value on one site and try to see it on the other and session value returns as null. The very same test page works on IIS7.
Does anyone know why IIS8.5 has trouble with something works on IIS7?
You need to add a machine key that's the same to both web config files.
If goes in system.web and looks something like this:
<machineKey validationKey="[your key]" decryptionKey="[dec key]" validation="SHA1" />
There are a few tools if you Google it that will create one for you.
There are a few reasons why you need this key, mostly because the servers might have different paths to the folder where you code lies or different IIS settings.

Chrome ASP.NET session vanishes

I'm using ASP .NET with VB, no other frameworks or Ajax, only ASP Charts.
web.config:
<sessionState mode="InProc" cookieless="false" timeout="20" cookieName="ASPMPT"/>
Logging in is done via a form and SQL.
The session times out after 10-20 seconds, and I see that Session_End from global.asax is called, then a new session is created. This happens only in Chrome, the other browsers work well.
I also tried using StateServer but no success.
ASP .NET State service is already started.
Set mode="StateServer" in web.config and do the following steps on your server :
Start
Control panel
Administrative tool
Services (you can also run services.msc to get there)
Find ASP.NET State Service
Right-click
Start

session variables losing value in deployed application

When application is deployed on server and accessed from the client, the session variables are blank
If IsNothing(Session("Order")) Then is always returning true.
The session variables have values when tested on the development machine.
This is the entry in web.config
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="true" timeout="60" />
When are you setting the session? Also, is this hosted? Some 3rd party hosts recycle worker processes/application pools constantly and it kills your session. Make sure you have your own application pool as well. Also, cookieless could be a problem for you.

session time out

I use asp.net and set the session timeout using
Session.Timeout = 1440;
but the session timed out, is there anything shall I fix or adjust in iis 7 and 6
Best regards
This may work
<configuration>
<sessionstate
mode="inproc"
cookieless="false"
timeout="1440"
/>
</configuration>
If the sessionstate timeout in the web config is not working check for memory leaks in your application. I had the same problem in a legacy application I inherited. After a lot if digging I found some custom server controls with static variables and static objects referenced by multiple pages and other objects. This caused the application to never release resources. Eventually IIS recycles the pool when it runs out of memory. When the pool is recycled all sessions will be unloaded from memory also.

Resources