Hello All,
I am trying to redirect users to a standby webpage in case our application
is down due to database server failure. To facilitate this I am opening a
test connection within a try/catch block in application_beginrequest event of
global.asax and in case the connection could not be established, I am
redirecting the users in the catch block.
Now to the interesting part. I am in the testing phase of this feature.
Since our production and development database server are the same I am using
a different approach to test this. I am running the application from my local
machine's web server and I am unplugging the network jack to simulate the
database server failure which is located at some other place.
So, once I unplug the network jack, the very first request should be
redirected to standy page because techinically the connection to Oracle
should not be established. But surprisingly this request is able to make a
database connection even though there is no network connectivity. When I
tried to debug and see, the execution was going well past the
OracleConnection.open() successfully and not going into the catch loop. But
the next request following this request is going into the catch block and is
redirected. What is the reason behind this strange behavior. Does .NET cache
the OracleConnections?
Here is the code....
System.Data.OracleClient.OracleConnection myDBConn =
new System.Data.OracleClient.OracleConnection();
try
{
myDBConn.ConnectionString =
System.Configuration.ConfigurationSettings.AppSett ings["ConnectionString"];
myDBConn.Open();
}
catch(OracleException ex)
{
//Database server is down; Redirect to standby page
}
Thanks a lot!!!