473,508 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Issues with Server.ScriptTimeout (and HttpContext.Current.Server.ScriptTimeout)

Hi all,

Am I right in thinking that if I set Server.ScriptTimeout to, say, 600 that
every request for an .ASPX page will wait up to 600 seconds before
responding with a "Request Timed Out" exception?

If I am right, then something screwy is going on with my server. Allow me to
explain.

I have a wee page that sends 30 emails out to various people in our company
using a mailserver which is on the same machine, and using the standard
System.Web.Mail classes.

It's taking around 2-3 seconds per email, and - as you can guess - when it
gets to emails 26 to 30, the ASPX page responds with a
System.Web.HttpException: Request Timed Out exception.

My solution is to grab the current value of Server.ScriptTimeout, reset
Server.ScriptTimeout to 600, and once the loop is finished (or on
Page.Error) it sets it back to the grabbed value.

Except it doesn't.

I've set it to 600 (Server.ScriptTimeout = 600 ' 10 Minutes) and started it
again.

No joy. Request timed out. Grr.

Is there something I'm not doing properly, or do I have to set the
ScriptTimeout somewhere else, or do I have to do it in the web.config file
or...

Help! Please!

Thanks,
Anthony
Nov 18 '05 #1
6 16062
Hi Anthony,

Thank you for posting to the MSDN newsgroups.

There are a lot of possible reasons for the "Request Timed Out" exception.
Based on my research and experience, please try the following methods to
work around this issue on your side.

Method 1: Set the ExecutionTimeout Attribute Value in the Web.config File
1. Open the Web.config file in Notepad.
2. Add the httpRuntime element in the system.web section as follows:

<configuration>
<system.web>
<httpRuntime executionTimeout="90" maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8" minLocalRequestFreeThreads="4"
appRequestQueueLimit="100" />
</system.web>
</configuration>

3. Modify the value of the executionTimeout attribute to avoid time-out
errors.
4. Save the Web.config file.

Method 2: Set the ExecutionTimeout Attribute Value in the Machine.config
File
1. Open the Machine.config file in Notepad. The Machine.config file is
located in the
%SystemRoot%\Microsoft.NET\Framework\%VersionNumbe r%\CONFIG\ directory.
2. In the Machine.config file, locate the httpRuntime element. The
Web.config file is located in the Web Application directory

<httpRuntime executionTimeout="90" maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8" minLocalRequestFreeThreads="4"
appRequestQueueLimit="100" />

3. Modify the value of the executionTimeout attribute to avoid time-out
errors.
4. Save the Machine.config file.

If the above methods cannot resolve the problem, please do not "sets it
back to the grabbed value" and test this issue again.

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #2
Jacob,

Thank you for the reply. Unfortunately, none of your suggestions worked, and
I do not have access to the machine.config file on my hosting server.

Worth noting is that the machine.config suggestion didn't solve the problem
on my local machine.

I've tried setting the Server.ScriptTimeout value on the page and forcing a
second postback after the ScriptTimeout page was set, but still... no joy.

Any help would be great. Please though, I really need to be able to alter
the amount of time a page will spend on processing!

Cheers,
Anthony

"Jacob Yang [MSFT]" <ji***@online.microsoft.com> wrote in message
news:AI**************@cpmsftngxa06.phx.gbl...
Hi Anthony,

Thank you for posting to the MSDN newsgroups.

There are a lot of possible reasons for the "Request Timed Out" exception.
Based on my research and experience, please try the following methods to
work around this issue on your side.

Method 1: Set the ExecutionTimeout Attribute Value in the Web.config File
1. Open the Web.config file in Notepad.
2. Add the httpRuntime element in the system.web section as follows:

<configuration>
<system.web>
<httpRuntime executionTimeout="90" maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8" minLocalRequestFreeThreads="4"
appRequestQueueLimit="100" />
</system.web>
</configuration>

3. Modify the value of the executionTimeout attribute to avoid time-out
errors.
4. Save the Web.config file.

Method 2: Set the ExecutionTimeout Attribute Value in the Machine.config
File
1. Open the Machine.config file in Notepad. The Machine.config file is
located in the
%SystemRoot%\Microsoft.NET\Framework\%VersionNumbe r%\CONFIG\ directory.
2. In the Machine.config file, locate the httpRuntime element. The
Web.config file is located in the Web Application directory

<httpRuntime executionTimeout="90" maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8" minLocalRequestFreeThreads="4"
appRequestQueueLimit="100" />

3. Modify the value of the executionTimeout attribute to avoid time-out
errors.
4. Save the Machine.config file.

If the above methods cannot resolve the problem, please do not "sets it
back to the grabbed value" and test this issue again.

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #3
Hi Anthony,

Based on my further research, it was found that there are two related
settings on this issue. One is the executionTimeout property in web.config
or in machine.config file; the other is the "ASP Script Timeout" property
in IIS. We should make sure both of the settings above should be set to an
appropriate value.

As for the "ASP Script Timeout" property in IIS, please follow the steps
below,

1.Open Internet Information Service manager.
2.Expand the appropriate nodes till the virtual directory where the ASP.NET
web app located.
3.Right click the virtual directory and select Properties.
4.Click the "Configuration¡*" and then switch to the Options tab.
5.Change the "ASP Script Timeout" property to an appropriate value.
6.Restart the IIS and try it again.

Please let me know if it helps.

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #4
Hi Anthony,

Thank you for your update.

Is it possible for you to show a simple testing sample code here and tell
me how to reproduce the problem step by step on my side? It will be very
helpful to the trouble shooting. I certainly appreciate your time.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #5
Jacob,

Since I've re-written the code, and my only backup of the old code is on a
SourceSafe server which is currently unavailable to me, I'll have to do it
from memory.

Basically, we had code retrieving around 34 records from a database, looping
through each of them, sending an email, and then returning to the page.

Our outgoing email server insists on performing an MX lookup on all domains
and checking to see if the target email address exists - this takes around
3 to 4 seconds per request - and this is why we need to increase the
timeout.

On our development server and production server we're using Merak Mail
Server which appears to insist on doing the MX Lookup, but also appears to
do it synchronously - a pain for us in this respect.

As mentioned, I've already re-written the code using asynchronous calls and
delegates, but I'd really like to know why Server.ScriptTimeout is not
apparently working.

So...

' --- CODE BEGINS ---

Imports System
Imports System.Data.SqlClient
Imports System.Web.Mail

Public Class MailTest

Private Sub Page_Load(ByVal sender As Object, _
ByVal e As EventArgs) Handles MyBase.Load

Server.ScriptTimeout = 180
StartNewTest()

End Sub

Private Sub StartNewTest

Dim cmd As New SqlCommand("ERTGetRecipients")
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = New SqlConnection( _
ConfigurationSettings.AppSettings("ConnectionStrin g"))

Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
da.Dispose()
cmd.Connection.Dispose()
cmd.Dispose()

For Each dr As DataRow In ds

Dim msg As New MailMessage
msg.To = "..."
' ...
' other code here
' ...

SmtpMail.Send(msg)

Next

End Sub

End Class

' --- CODE ENDS ---

Your help is much appreciated!

Regards,
Anthony

"Jacob Yang [MSFT]" <ji***@online.microsoft.com> wrote in message
news:xc**************@cpmsftngxa07.phx.gbl...
Hi Anthony,

Thank you for your update.

Is it possible for you to show a simple testing sample code here and tell
me how to reproduce the problem step by step on my side? It will be very
helpful to the trouble shooting. I certainly appreciate your time.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Nov 18 '05 #6
Hi Anthony,

Thank you for your update.

As I understand, you have found a workaround for this issue. Now your
concern is that why the Server.ScriptTimeout is not apparently working.

As I have mentioned before, there are a lot of possible reasons for the
"Request Timed Out" exception. The Server.ScriptTimeout does not work here
because it is not the root cause of this specific problem. Thank you for
your understanding.

I have found an example of how the Server.ScriptTimeout works. Please refer
to the following Knowledge Base article.

PRB: Response.WriteFile Cannot Download a Large File
http://support.microsoft.com/default...b;en-us;812406

The workaround in the above article works fine when set debug = "true" in
the web.config file. But when set debug = "false" in the web.config file,
the downloading cannot be finished. The follows are the reproducing steps:

1. Setup a Windows XP Pro machine with VS.NET 2003.

2. Create a default C# web application.

3. Add a button to the web form and add the C# work around downloading code
to the button click event handler.

4. Change the ¡°DownloadFileName¡± to a large file (200M).

5. Set debug = "false" in the web.config file.

6. Change to the release mode and rebuild the solution.

7. On another Windows XP Pro machine (client), access the web form and
click the button to download the large file.

8. The client will not get the entire file. (Only about 80M is downloaded.)

The solution is using the Server.ScriptTimeout.
...
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Server.ScriptTimeout = 360;
}
...

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
23983
by: Bryan | last post by:
I'm looking for a definitive answer to a Server.ScriptTimeout question. if I add <% Server.ScriptTimeout = 300 %> to a page, does that then alter the default 90 second script timeout for ALL...
0
1598
by: srt | last post by:
Hi, I have some problems with setting Server.ScriptTimeout. The posted script doesn't stop after 120 seconds (the timestamps are displayed after the 120 seconds and I stopped the server after 5...
13
1760
by: Fernando Chilvarguer | last post by:
Hi, I'm retriving data from a database and storing it on the Cache Object using the following code: HttpContext.Current.Cache.Insert( cacheItemKey, contentDS, //THE DATASET WITH MY DATA...
2
2464
by: jakk | last post by:
Iam storing the session state in SQL Server. The Session gets stored in the SQL Server temp tables ( I can see some values in the two tables), but the session doesnt seem to timeout. We have a...
2
1540
by: Yogesh Pancholi | last post by:
For some unexplained reason, I am suddenly unable to browse to a virtual directory on my laptop. I have a number of sample websites to which I could happliy browse up until last week. As of Monday,...
3
1925
by: Steve Lutz | last post by:
Hello All, I have an ASPX page whose class inherits from a company global base page. The company base page has a property call PageTitle (string) that is assigned by all the pages. The base...
10
3061
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web...
0
1073
by: fabrice | last post by:
Hello, I have got a little problem with Url Rewritig process and server.transfer use. I would like to create a simple url rewriting process for my web site I use in a lot of pages, the...
2
3089
by: =?Utf-8?B?YWxiZXJ0b3Nvcmlh?= | last post by:
Hi, I'm using Threads, and when I try to do Server.Transfer, I recieved an error. (child object does not exist...) My Code: Dim t As New Thread(AddressOf Hilo) Private Sub Hilo()...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
422
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.