Search code examples
asp.net-mvc-2error-handlingconnection-timeout

How can I track server time outs programmatically?


We have a page that accepts video file uploads using a plain <input type="file" . We have had users (students in this case) complain that it's not working but not provide any type of error message or anything. If indeed there is a problem, I believe it would be a timeout error from trying to upload a large file on a bad connection. Is there anyway to track this to find out what they are trying to do and what the problem is?


Solution

  • Maybe they are trying to upload files larger than the maximum allowed file size or the request timeouts which could be controlled by the following section in your web.config:

    <system.web>
        <httpRuntime executionTimeout="110" maxRequestLength="20000" />
    </system.web>
    

    Also the server's EventLog probably contains some errors which could give you more clues.

    Another useful thing is to subscribe for the Application_Error event in your Global.asax and try to trace all unhandled exceptions which might occur:

    protected void Application_Error(object sender, EventArgs e)
    {
        HttpApplication app = (HttpApplication)sender;
        HttpContext context = app.Context;
        Exception ex = context.Server.GetLastError();
        // TODO : use your favourite logging framework to trace the exception
        // so that you can later see what went wrong. At least you should get
        // the exception stacktrace.
    }