I hosted a web application on a (Live server) shared hosting, and did not get any issue until today when I decided to test-run it. I registered and logged in the web application with the test login details; I was redirected to the dashboard, but after some seconds I was redirected back to the login page (I got logged out). I don't know how this happened, it quickly logs me out and redirects me to login page. After this persisted, I contacted my hosting company then I was told that I maxed out my resource which was causing the issue. A worker process with id serving application pool 'website domain name(domain)(4.0)(pool) has requested a recycle because it reached its virtual memory limit.
To be honest, I don't know how this happened because the application has been on a live server for months without this issue. However, I will like to know if this can be resolved and also prevent a re-occurrence?
Please can anyone help me with details of how to resolve this?
Could it be that there is something I did or didn't do in my web.config file?
<configuration>
<connectionStrings>
<add name="ConString" connectionString="My Connection String goes here"/>
</connectionStrings>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<system.web>
<sessionState timeout="30"></sessionState>
<trust level="Full" />
<authentication mode="Forms">
<forms timeout="30" cookieless="UseCookies" loginUrl="https://mywebsite.com/login" defaultUrl="https://mywebsite.com/home" slidingExpiration="true" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" maxRequestLength="3145728" />
<customErrors mode="Off" />
<pages enableEventValidation="false">
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
</controls>
</pages>
<machineKey validationKey="***" decryptionKey="***" validation="SHA1" decryption="AES" />
</system.web>
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear />
<add value="Default.aspx" />
</files>
</defaultDocument>
</system.webServer>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483644"></jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="***" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.9.0.0" newVersion="1.9.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="***" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="***" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="***" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging" publicKeyToken="***" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom></system.codedom>
</configuration>
I also have this page load event on every page on the application
protected void Page_Load(object sender, EventArgs e)
{
if (this.Page.User.Identity.IsAuthenticated && Session["user"] != null)
{
labelid.Text = Session["user"].ToString();
Showdata1();
}
else
{
Response.Redirect("login");
}
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
Response.AppendHeader("Pragma", "no-cache");
}
I have also been thinking if it came as a result of using 3rd party API like ip2location to get user's local time zone
private void LastLogin()
{
string connectionString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
using (SqlConnection con = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand("SELECT LastLogin FROM UserTable WHERE id = @id", con))
{
cmd.Parameters.AddWithValue("@id", Session["user"]);
con.Open();
DateTime time1 = Convert.ToDateTime(Session["LastLogin"]);
TimeZoneInfo serverTimeZone = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
TimeZoneInfo userTimeZone = TimeZoneInfo.FindSystemTimeZoneById(GetTimeZoneNameByOffsetTime(this.GetLocation().time_zone.Replace("+", "")));
DateTime userLocalTime = TimeZoneInfo.ConvertTime(time1, serverTimeZone, userTimeZone);
Timelbl.Text = userLocalTime.ToString("dddd, MMMM d, yyyy h:mm tt");
}
}
}