protected void btnDownloadTrial_Click(object sender, EventArgs e) { //Get the user data from the form TrialUser trialUser = new SqlDatabaseManager.SimpleSqlite.TrialUser(); trialUser.Email = "*****@*****.**"; trialUser.Name = "test name"; trialUser.Version = ConfigurationManager.AppSettings["Version"]; ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["SimpleSqliteDatabaseConnString"]; if (connectionStringSettings == null || string.IsNullOrEmpty(connectionStringSettings.ConnectionString)) { //throw error and return return; } Database.TrialDatabase.AddTrialUser(trialUser, connectionStringSettings.ConnectionString); //SEE IF THIS CAN BE REFACTORED INTO ONE HANDLER Response.Redirect("TrialDownloadAPI.ashx", false); //Response.Redirect("TrialDownloadUtility.ashx", false); }
public void ProcessRequest(HttpContext context) { try { //Save a trial user to the database string version = ConfigurationManager.AppSettings["Version"]; if (string.IsNullOrEmpty(version)) { //throw error and return return; } string trialDownloadPath = "~\\Releases\\" + version + "\\Downloadables\\Trial\\SimpleSqlite.zip"; //Transmit the files System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); response.ContentType = "text/plain"; response.AddHeader("Content-Disposition", "attachment; filename=SimpleSqlite.zip;"); response.TransmitFile(trialDownloadPath); TrialUser trialUser = new SqlDatabaseManager.SimpleSqlite.TrialUser(); trialUser.Email = "*****@*****.**"; trialUser.Name = "test name"; trialUser.Version = ConfigurationManager.AppSettings["Version"]; ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["SimpleSqliteDatabaseConnString"]; if (connectionStringSettings == null || string.IsNullOrEmpty(connectionStringSettings.ConnectionString)) { //throw error and return return; } Database.TrialDatabase.AddTrialUser(trialUser, connectionStringSettings.ConnectionString); response.Flush(); response.End(); } catch (Exception ex) { //Pop up dialog to let user know an error occurred } }