I am using sql server and sometimes my database goes down for maintenance. I have error handling code so the user don't see error page, instead they see a nice and friendly error message. My question is: When the database is down, It takes an awfully long time for the page to load and show the error message. I thought it had something to do with the timeout property, but changing it using
command.CommandTimeout = 5;
or
Connect Timeout=5;
in web.config in connectionString
doesn't seem to help and it still take a long time for the page to load (about 40 sec). Is there a way to minimize this time?
The exception that gets thrown and logged is
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)