protected void btnKey_Click(object sender, EventArgs e) { String dbConnectionString = ConfigurationManager.ConnectionStrings["DataExplorerDatabase"].ConnectionString; session loggedInUser = null; /* Validate the description */ string newDescription = txtDescription.Text; if (newDescription.Length > 0) { using (SqlConnection connection = new SqlConnection(dbConnectionString)) { loggedInUser = session.loadThisSession(connection, getSessionIDFromCookies(), Request.ServerVariables["REMOTE_ADDR"], Request.ServerVariables["HTTP_USER_AGENT"]); if (loggedInUser != null) { APIKey.createAPIKey(connection, loggedInUser.getUsername(), false, newDescription, Request.ServerVariables["ALL_RAW"] + DateTime.Now + loggedInUser.getUsername() + loggedInUser.getIP()); refreshKeyList(); txtDescription.Text = "Enter a description here"; } } } }