Click here to Skip to main content
15,884,635 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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:
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)
            'foo
        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
Posted
Updated 9-Aug-18 2:52am
v4
Comments
ZurdoDev 7-Aug-18 12:30pm    
I'm not sure what is going on but I would suggest firing it off asynchronously or using a different method altogether. 100 minutes is a crazy time for a browser to sit there waiting. Any number of things can go wrong during that time.
Sni.DelWoods 9-Aug-18 3:32am    
Thanks. Could you give me a short code snippet how to do this asynchronously?
I tried the script on a new website, without web.config or any other configurations. I have the same result.

1 solution

probably solved.

Changed web.config:
<compilation debug="false" targetFramework="4.7">

to
<compilation debug="true" targetFramework="4.7">


This option overrides the execution timeout to infinite.
After checks I'll change back to false and set httpruntime execute timeout and other parameter.

Source:
debug-true-in-web-config-bad-thing
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900