I've been through almost all sorts of Timeout related issues with Asp.net web service development. I’d like put a check list here to remind myself and hopefully save some headache of yours.
- If use database, you may get ‘System.Data.SqlClient.SqlException: Timeout expired’:
a: Check your connection string setting for ‘Connect Timeout’: I.e.
connectionString="Data Source=SNYC14D11511;Initial Catalog=d_dbivt003;Persist Security Info=True;User ID= user;Password= Password;Connect Timeout=4200
b:Check your command object SqlCommand.CommandTimeout Property, it’s by default 30s
- Check you Web.config setting when you get error like ‘Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'.’:
make sure your set 'compilation debug="false" as well to let timeout setting take effect. Check MSDN for details.
- Set your proxy class Timeout property (derived from WebClientProtocol.Timeout Property) at client if you get error like this ‘The operation has timed out’: I.e.
proxy.Timeout = System.Threading.Timeout.Infinite;
- If you are like me, use VistualStudio unit test tool and you get a blue icon and error ‘Timeout’ in your test result pane, you need to check your test config file localtestrun.testrunconfig. The last item ‘Test Timeouts’ is the key. It’s 5 min by default.
- Last one and every web developer should know is the IIS server setting such as Keep Alive and Connection Timeout