ASP.NET Connection to MYSQL Database connection not open on session start

VBULETiN

New Member
I have a general question to see if anyone has heard of something like this. My website when it tries to connect to my MySQL database (I am on a shared server) returns an error Server Error in '/' Application.Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Connection must be valid and open.Source Error: Line 57: Line 58: Line 59: Line 60: Line 61: Source File: D:\hshome\c372639\edutomebooks.com\web.config Line: 59 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 I understand what is happening. Web.config is trying to start up the session state by accessing the session state tables in my database. I have never had this problem on my local computer when debugging and testing there. I can't tell if it is something in my code or project or if it is a problem with the server. This problem only happens when you first try to access the website. Once the connection is made after several refreshes the site works fine and the speed is pretty good too. This is what I tried to do to fix the problem after some research on the problem. I tried adding to Global.asax \[code\] public class Global : System.Web.HttpApplication { private MySqlConnection conn = new MySqlConnection(getbooks.get_cString()); protected void Application_Start(object sender, EventArgs e) { conn.Open(); while (!conn.Ping()) { conn.Close(); conn.Open(); } } protected void Session_Start(object sender, EventArgs e) { } protected void Application_BeginRequest(object sender, EventArgs e) { } protected void Application_AuthenticateRequest(object sender, EventArgs e) { } protected void Application_Error(object sender, EventArgs e) { } protected void Session_End(object sender, EventArgs e) { } protected void Application_End(object sender, EventArgs e) { conn.Close(); } }}\[/code\]
 
Back
Top