How to set the timeout for a webservice call .Net

There are a number of things that can time out in a webservice so this question has a few parts to it.  Among the things that can time out the main ones are:

1) The client making the call (your web app for example)
2) The webservice itself (by default a web method has a max run time set by the web.config / IIS)
3) Generally timeouts are related to database calls that take too long.  Your data call can time out getting data from the database.

Now generally you shouldn’t be extending timeouts if your app is taking too long to run.  If your app is timing out chances are your app is doing something wrong and is simply too slow.  Perhaps you should put the long running process on another thread?  Or improve your SQL?  Or maybe it actually is a hardware / network bottle neck.  The best reason I can think of for wanted to extend the timeout on a web-service is when you are in debug mode and having the service timeout during debugging is annoying and time wasting.

In any case, if you do genuinely need to extend the timeout for a web service add this to your web.config:
<httpRuntime executionTimeout=”600″ />
This node is a child of <system.web />

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: