I am working on an ASP.NET 2.0 website. The issue that I’m having is that it queries a database to get the info it displays on screen, but the database occasionally gets to where it has too many open connections. This causes the website to reject the attempt to log-in for anyone, after that database error.
This is caused because many users will log-in, do what they need to do, but then leave the website running while they do other things without logging out. It will time out on them, but the connection still seems to be open. We then have to contact the person in charge of the server it’s running on and have him reset it for us.
I have looked and all connections made to the database seem to be closed after the request and query is made. So, what I want to do is to add a button that when clicked will reset the website, instead of having to call the guy in charge of the server every time. Then we can reset it whenever we need to. So, how do I reset an ASP.NET 2.0 website with a button on one of the pages inside the site?
Many thanks,
Mike
The problem here is the word “seem”. For example, this code “seems” like it will close the connection, but in some situations it won’t:
I can hear you saying, “Of course it closes the connection. Don’t you see the ‘conn.Close();’ line?” The problem is that there are things that can happen that prevent the conn.Close() line from executing.
Instead, you need to do something like this:
That code will always close the connection.
If you’re really serious about “resetting” the application, you might try calling
Environment.Exit(), but again: this is a bad idea.