How to Fix 'Timeout expired. The timeout period elapsed prior to completions of the operation'
by
Doug
Updated January 28, 2011
Timeout expired SqlException error.
On a number of a occassions I've run into the following ASP.NET / IIS7 error after uploading my newly built Visual Studio.net web project site into IIS (where the site had previously been working fine):
'Timeout expired. The timeout period elapsed prior to completions of the operation or the server is not responding.'
The site would be running perfectly on my local computer, but once uploaded to my production server I would get the SQLException Timeout expired error. While this Timeout expired error can happen due to any number of reasons, I've found that sites, which had been working fine until uploaded a new build of the site to IIS7, that the reason I would get this error was because something was wrong with the "Build" version of the Visual Studio.net web Project and/or Solution files. So essentially I found that I just needed to run the Project/Solution through a "Rebuild" using Visual Studio.net (not just a "Build").
For whatever reason, it seems like something occassionally will get corrupted on regular "Build" of the VS.net web Project and/or Solution file. So if I just do a "Build" and upload the new project .zip file to my server and import it into IIS7, it won't correct the problem.
However, if I do a "Rebuild" of the Visual Studio.net Project and Solution and then import the project .zip file into IIS7, the 'Timeout expired' error goes away.
I've encountered this issue at least twice now, and at first it was somewhat daunting not knowing what exactly was causing the Timeout expired error. But after doing a "Rebuild" of my Visual Studio.net web project I've been able to get my sites up and running.
Lastly, make sure that you rebuild the project in Release mode (not Debug).
So I'm sure this tip won't help everyone to figure out what is causing your exact "Timeout expired" SqlException error, but hopefully the solution I provided above will come in handy for some of you who are experiencing the same sort of issues as I have.