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"
/>
Related
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
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.
I want to set timeout for my web application for 12 hours.
I have done setting in web.config file as:
<system.web>
<sessionState timeout="720" />
</system.web>
As suggested in the following post:
I came to know that the Application Pool recycles in every 20 minutes (if the pool is ideal).
And I also checked for changing the application pool time out using one question about application pool timeout setting
But still the session time-out is not set to 720 minutes. Do I need to change machine.config file for changing the session time out.
But I think the properties of machine.config file should be overriden by web.config file.
Kindly provide me some idea.
You can try out WMI(Windows Management Instrumentation) script it can help you.You need to have sufficient priveleges to implement the Script.
follwing are the links you can check to get more information.
http://bendera.blogspot.in/2010/12/configuring-ica-rdp-timeout-values.html
http://technet.microsoft.com/en-us/library/cc771956%28v=ws.10%29.aspx
You should set all following:
Application Pool / Advanced Settings. There the option Idle Timeout should be set in minutes.
Then within the web.config file in system.web section you should also set the Authentication/Forms, SessionState and RoleManager timeouts, if applicable.
<authentication mode="Forms"><forms loginUrl="~/default.aspx" name=".ASPXFORMSAUTH" timeout="120" /></authentication>
<sessionState cookieless="AutoDetect" cookieName="TYS_ADMIN_SessionId" timeout="120" />
<roleManager ... cookieTimeout="120" defaultProvider="GMRoleProvider" enabled="true">...</roleManager>
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.
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