0

the context : i am currently working on a website/wep app in my company containing a page which is used to send about 280 e-mails to some users.

all is working fine in the test server but on production server we got a timeout in the middle of the function (it take about 5 min to send everything) some users received the mail, some others no.

in the test server, all is working and i am the one who received all the mails, no error, no exception, no timeout.

By looking at another of our site which has the same functionality using almost the same code, i saw this at the beginning of the PageLoad : Server.ScriptTimeout = 600

the question :

My function sending a mail looks like this :

onclick()
{
    foreach()
    {
        sendmail()
    }
}

As the foreach takes about 5 min to iterate entirely, is it possible that an On_click event from a button trigs a timeout ?

thanks for helping

note : it's a custom button whith confirmMessage which block the page until the event clic is over.

note 2 : i don't see any problem in the code since the important sending part is copied on 1 of our working application, also i tried all the code while just commenting the message.send() function and there was no problem at all. it could be a problem from our mail address in database but i can't test them unless i send a real mail, and i don't want to send real mails as tests :)

Koyuki
  • 3
  • 2
  • Has this to be done with such long client side script? (yes timeout may be the reason if posts are synchronous). Why don't you collect everything, send to server with AJAX and then get response when done (all asynchronous). Take a look to [this post](http://stackoverflow.com/questions/4460263/disabling-the-long-running-script-message-in-internet-explorer) too. – Adriano Repetti Mar 20 '14 at 16:50
  • there is no long client side script for this page, or just some display features in javascripts. i don't think that using ajax will change anything in my case. All is executed from the code behind, so directly in the server. The function which create a list of email reveicer and create all the mail takes about 1 sec to process, then it's the fucntion which iterate this list and sending 1 email for each iteration who takes so much time, also in the codebehind. – Koyuki Mar 20 '14 at 17:44

1 Answers1

1

Yes, an OnClick event can timeout.

The default timeout for IIS is 110 seconds (refer to MSDN doc). You can change the max executionTimeout in the web.config using <httpRuntime executionTimeout = "HH:MM:SS" />

When you're debugging, the executionTimeout property is not applied. This is why you didn't see the problem while you were developping your function.

If you call your function using Ajax (through ScriptManager), you can set a different time for the maximum execution time with the AsyncPostBacTimeout property.

Gabriel GM
  • 6,391
  • 2
  • 31
  • 34
  • Hi, it seems like the time out was the problem. I simply add this famous Server.ScriptTimeout = 600 and the problem didn't appear on the server on last test. It's a function which is used once per month (as mail reminder for users) let's see next month if i was lucky or if the problem is solved. – Koyuki May 28 '14 at 08:00