Thanks Satalaj, I did know about the Response.Redirect/ThreadAbortException issue you mention. That is not the source of my exceptions. My application is updating its own bin/ folder, triggering an application restart. If my thread takes more than two minutes to complete (not unusual), it gets aborted.
I actually read through the page you reference, as well as similar MSDN articles. Those led me to try changing the shutdownTimeout in processModel and in the application pool config. Neither of these worked - I still timed out at the 2 minute mark. Finally, I increased the shutdownTimeout in httpRuntime and that did work. I just don't know why it did.
That's my question - why did the httpRuntime change work when the other two did not. What's the difference or is there a difference? Is there a precedence I'm not accounting for? Something like that....
To test this, I created a simple page that updates a file in bin/ then sleeps for 3 minutes. Normally the page times out, but if I set <httpRuntime shutdownTimeout="240" ... /> in my web.config, the page runs to completion. Changing the other two shutdownTimeouts I mentioned did not yield this result.
Following is the page I used to test this:
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Threading" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Sleep</title>
<script language="C#" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
lnkReset.NavigateUrl = Request.Url.ToString();
}
protected void cmdSleep_Click(object sender, EventArgs e)
{
// Amount of time to sleep after triggering the restart.
int sleepSeconds = 180;
// File to create/touch in bin folder to trigger restart
string path = Server.MapPath("bin/sleep.txt");
if (File.Exists(path))
File.SetLastWriteTime(path, DateTime.Now);
else
File.Create(path).Close();
Thread.Sleep(sleepSeconds * 1000);
cmdSleep.Visible = false;
lnkReset.Visible = true;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:LinkButton ID="cmdSleep" runat="server" Text="Go" onclick="cmdSleep_Click" Visible="true"/>
<asp:HyperLink ID="lnkReset" runat="server" Text="Reset" Visible="false" />
</div>
</form>
</body>
</html>