Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting Application Pool idletimeout to 0 side effects

I have a web application running under IIS7. I am storing my global variables in a class with static variables. The class is called SessionVariables and inside it for example I have the following :

public class SessionVariables
{
    public static string PreferedColor= "Black"; 
}

I am setting this variable in another page AccountSettings.aspx where I have a dropdown with colors names. When the user selects a color , and clicks on save that's the code that is running.

   protected void btnSave_click(object sender, EventArgs e)
    {
    SessionVariables.PreferedColor= ddlColorNames.Text;
    }

if the application went idle for 5 minutes the static value of PreferedColor is always reset to default because the application pool settings was clearing the static values since the idle time-out (minutes) was set to 5. I changed it to 0 from IIS application pool and the problem disappeared, The application pool is not recycling anymore. I would like to know if there are any side effects for this setting.

like image 882
James Dayeh Avatar asked Oct 30 '25 09:10

James Dayeh


2 Answers

It means that the application pool process won't shut itself down even after an extended period of no connections. If you're not worried about clearing out the resources during low-usage periods leaving it off is totally fine.

You will still have your variables wiped if other recycles occur, if you want to avoid that you need to properly store your variables not just in memory (likely in a database).

like image 197
Stephen S. Avatar answered Nov 01 '25 12:11

Stephen S.


Solved, it was a missing configuration in web.config that was clearing the static variables after 5 minutes I have added the following and all went well

<sessionState mode="InProc" cookieless="false" timeout="480"/>

and

 <forms loginUrl="~/Login.aspx"  slidingExpiration="true" timeout="480" />
like image 41
James Dayeh Avatar answered Nov 01 '25 14:11

James Dayeh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!