What's wrong? My webform is performing a postback after 100 minutes by itself.
I created a very simple form for testing with a log file.
I open the website in the browser, click the button and close the browser (script runs on the server without browser output).
The Button1_Click event runs a loop for 120 minutes.
The log gives me
Form1: Load
Button1_Click: Start
After 100 minutes IIS does a postback itself.
Final log is:
Form1: Load
Button1_Click: Start
Form1: Load
Button1_Click: Start
The Button1_Click:End is never reached.
I noticed this behaviour some months ago on a form which needs some hours to fetch some data from a webservice.
Does anyone have an idea?
I haven't change anything in the procecure or IIS6 or web.config.
What I have tried:
timeoutcheck.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="timeoutcheck.aspx.vb" Inherits="_timeoutcheck" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="form1" runat="server">
<p><%=Date.Now.ToString() %></p>
<p><asp:Button runat="server" ID="Button1" Text="Start" /></p>
<p><asp:Button runat="server" ID="Button2" Text="Dummy" /></p>
</form>
</body>
</html>
timeoutcheck.aspx.vb:
Partial Class _timeoutcheck
Inherits System.Web.UI.Page
Private Sub form1_Load(sender As Object, e As EventArgs) Handles form1.Load
DoLog("Form_Load")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim dStart As Date = Date.Now
Dim timeoutMinutes As Integer = 120
DoLog("Button1_Click:Start")
Do While Date.Now < dStart.AddMinutes(timeoutMinutes)
Loop
DoLog("Button1_Click:End")
End Sub
Private Sub DoLog(messageInfo As String)
Dim subject As String = "Timeoutcheck (" & HttpContext.Current.Session.SessionID & ")"
Dim message As New List(Of String) From {
"#### " & subject,
messageInfo,
Date.Now.ToString() & "." & Date.Now.Millisecond,
"Postback: " & IsPostBack,
"Send: " & If(Request.UrlReferrer Is Nothing, "--", Request.UrlReferrer.ToString()),
Environment.StackTrace,
"--------------"
}
Using stmWriter = New System.IO.StreamWriter(Server.MapPath("~/timeoutcheck.log"), True)
stmWriter.WriteLine(String.Join(vbCrLf, message.ToArray()))
stmWriter.Close()
End Using
End Sub
End Class