I noticed that while debugging my applications, sometimes the [InProc] Session State is destroyed following re-builds (C# Web Application). The sequence of events are as follows:
- Rebuild & run application (Debug or Release Mode, Doesn't Matter)
- Populate a Session Variable in Page_Load() Event
- Session_End() fires then Application_End fires()
- I perform a postback and check for Session variable populated in Step 2, it is empty.
I am running this application using IIS Express, but it seems to occur irregardless of which web server is being used. This is causing numerous problems as the application isn't counting on Session variables to vanish.
namespace BlankWebApp
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["test"] = true;
}
}
protected void butCheckSession_Click(object sender, EventArgs e)
{
if (Session["test"] == null)
{
// Session_End and Application_End must have been called
}
}
}
}