GoDaddy (CentriqHosting): Data driven Web Application Deployment Process Summary There a several steps to deploying an ASP.NET website that includes databases (for membership and/or for site content and functionality). This hand out outlines those steps for the Centriq track, including: 1. Create root level application directories: Since we would like to treat our "sub sites" of WG, SAT and TST like they are their "own websites", even though they will be hosted just as subfolders off our domain, we will need to configure these subfolders to be considered "rootlevel applications" by the GoDaddy web server. We do this in the GoDaddy Control Panel. a. This will allow, for example, the root web.config file for WG to not conflict with the root web.config file for the Personal Site and for WG's masterpage that uses root relative referencing to only go back to WG's root folder and not the root folder for the Personal Site that contains WG. 2. Create the remote database: Create the SQL Server database on the GoDaddy database server (through the Control Panel). a. There will only be one SQL Server database on GoDaddy, so all the different databases we were using for different websites locally will be recreated into this one database on GoDaddy. So all table names should unique unless you changed their schemas to avoid conflicts. 3. Save a connection to remote database in SSMS: Create a connection in Management Studio that accesses the remote database with the GoDaddy hostname, username and password. 4. Use "Generate Scripts" option in SQL Server Management Studio and migrate all data tables to the remote database: For each database you are using with your local websites (other than membership databases, which are discussed later) you'll create a SQL script for re generating the structures, relationships and data. You then run the script inside Management Studio while connected to your remote GoDaddy database, populating it with your data tables. 5. Update the connection strings: a. For each connection string that already exists in the web.config files of your sites (connecting to the local instance of a database on your machine), you will need to create an alternate version of that same connection string tag that points to the remote instance of the database. b. Also, for any websites using membership and authentication, in the root web.config we will need to add code to remove the default LocalSqlServer connection string and then recreate one that points to the GoDaddy database. The LocalSqlServer is a special name for the Asp.Net Membership connection string, and must be present on your live site. 6. Recreate users/roles in the GoDaddy database: Using the WSAT (after updating the LocalSqlServer connection string to point to the GoDaddy database), we will replicate the roles and new live users from each local site. This will essentially recreate the membership database tables remotely. a. Keep in mind this means that on your live site, since there is only one set of membership tables, users and roles will be shared across all sites hosted off your domain. So logging into your deployed WG site would, for example, mean you would be considered a logged in user for your deployed SAT site, as well. 7. Upload the website files and test: Use Filezilla to upload the website files from your local folder to the GoDaddy web server. Especially be sure to upload your web.config file while it has the remote connection strings live and the local connection strings commented out.
Table of Contents GoDaddy (CentriqHosting): Data driven Web Application Deployment 1 Process Summary 1 Creating the Root Level Application Directories (for TST, WG, and S.A.T.) 2 Creating the Remote Database (GoDaddy SqlServer) 3 Create an SSMS Server Name to Your GoDaddy Database 3 Backing up your database using Generate Scripts in Management Studio 4 Update Connection Strings for GoDaddy Database in the Web.config of Each Site 5 Final Deployment Connection Strings Code Sample 6 Recreate Your Membership Data to Your GoDaddy Database 6 Creating the Root Level Application Directories (for TST, WG, and S.A.T.) 1. Log in to CentriqHosting.com 2. Access the Hosting Control Panel (in the Web Hosting section, click the Launch button). 3. On the navigation bar at the top of the Control Panel, hover over the More dropdown menu: a. Click on IIS Management b. Click the Create button underneath the Settings tab c. You will create 3 separate directories, called: TST, WG, and SAT i. For each directory created be sure to check Set Application Root this allows you to deploy application level Web.config files to those directories, which is the way all of you projects are currently built. (Leave Anonymous Acccess checked and Directory Browsing unchecked.) Then click OK. ii. Each folder will be in a Pending Setup state for a few minutes. v20130920e GoDaddy Data Driven Web Application Deployment page 2
Creating the Remote Database (GoDaddy SqlServer) 1. Log in to CentriqHosting.com 2. Access the Hosting Control Panel (in the Web Hosting section, click the Launch button). 3. On the navigation bar at the top of the Control Panel, hover over the Databases dropdown menu and choose SQL Server. a. A modal pop up for Manage Databases appears. b. Click the Add button c. Add a Friendly name as a description for you to recognize the database it can be anything. i.e.: Chuck s Database d. Add a Database name and username for accessing your database (it will be the same name for both) e. Add and confirm a Password for accessing your database f. Expand the Additional Options section: i. Skip "readonly username" and the related password fields. ii. CHECK the ASP Schema check box. This installs the membership and profile tables for you. iii. If you miss this additional option, you may need to delete the database and recreate it with these settings in order to use it. g. Click the OK button h. The database will be in a Pending Setup state for about 20 minutes. Create an SSMS Server Name to Your GoDaddy Database Set up Microsoft SQL Server Management Studio to use an alternate server (here, the GoDaddy server): Open Microsoft SQL Server Management Studio. Change the server name. You can find the path to use in the GoDaddy Control Panel. o On the navigation bar at the top of the Control Panel, hover over the Databases dropdown menu and choose SQL Server. Click the Actions button, then choose Details from the dropdown menu. Copy the path under HostName and paste that as the Server name in SSMS. In SSMS, change the Authentication from Windows to SQL Server Then add your database Login and Password. o (Login will be your username, which is the same as the database name.) Check Remember password, then click Connect. (In the future you should be able to choose this connection from the Server Name dropdown anytime to connect to your live db server.) v20130920e GoDaddy Data Driven Web Application Deployment page 3
Backing up your database using Generate Scripts in Management Studio 1. Open SQL Server Management Studio and connect using.\sqlexpress server name 2. In Object Explorer, expand out the Databases 3. Right click the database you want to back up and choose Tasks Generate scripts 4. In the Generate and Publish Scripts wizard, click Next or click Choose Objects in the left column, then check the radio button option for Select specific database objects, then check Tables option. a. Uncheck any table starting with "sys" in the name. b. Check Views and/or StoredProcedures if needed. c. Then click Next. 5. Now in the Set Scripting Options in left column: click the Advanced button on the right. 6. Update the following option, then click OK: a. Change "Script DROP and CREATE": Script DROP and CREATE b. Change "Script USE Database": false c. Change "Types of data to script": Schema and data 7. Choose [ ] button for FileName, and browse to change the desired save location and rename the script to be created. a. Consider adding a manual date & timestamp to the filename, such as: TSTdb20131201_1430.sql and saving it to \Documents\SQL Server Management Studio\Projects 8. Go through the default options for the rest of the wizard. Next Next Finish v20130920e GoDaddy Data Driven Web Application Deployment page 4
Update Connection Strings for GoDaddy Database in the Web.config of Each Site 1. Add the following to the <connectionstrings> portion of the web.config in each project that will be deployed: <!--REMOTE Connection Strings Code--> <add name="localsqlserver" connectionstring="" 2. Copy the entire <add name= /> element that is being used by your SqlDatasources. In TST, it is probably called TSTConnectionString. Paste the copy underneath the code you just added and remove the content of the connectionstring attribute. It should look like this (note blank connectionstring attributes): <!--REMOTE Connection Strings Code--> <add name="localsqlserver" connectionstring="" <add name="tstconnectionstring" connectionstring="" 3. Log into the Control Panel in CentriqHosting, hover over the Databases dropdown menu and choose SQL Server. a. Click the Actions button, then choose Details from the dropdown menu. b. Click on the Code Sample button c. Copy the text for the SqlConnection (.NET): connection string section. 4. Paste that text in as the value for the two connectionstring attributes you just added to your web.config. Replace the 'Your Password' with your actual password. Be sure to remove the single quotes that were around 'Your Password'. 5. What you just added was the DEPLOYMENT version of your connection strings. Be sure it is uncommented when you deploy your web.config, and that the original (local) connection strings are commented out. Vice Versa when working locally. Final sample below: v20130920e GoDaddy Data Driven Web Application Deployment page 5
Final Deployment Connection Strings Code Sample <connectionstrings> <!-- LOCAL Connection Strings Code <add name="localsqlserver" connectionstring="data Source=.\sqlexpress;Initial Catalog=TSTMembership;Integrated Security=True" providername="system.data.sqlclient" /> --> <!--REMOTE Connection Strings Code--> <add name="localsqlserver" connectionstring="data Source=mydatabase.db.103456.hostedresource.com; Initial Catalog=mydatabase; User ID=mydatabase; Password=MyP@ssw0rd;" <add name="tstconnectionstring" connectionstring=" Data Source=mydatabase.db.103456.hostedresource.com; Initial Catalog=mydatabase; User ID=mydatabase; Password=MyP@ssw0rd;" </connectionstrings> Recreate Your Membership Data to Your GoDaddy Database After all this, you ll also need to create some real users (or test users) for each project on your GoDaddy database. You ll still do this through the WSAT in Visual Studio, but to do it for your GoDaddy database, you ll need to make sure your web.config is pointing to the GoDaddy database server. So, the remote connection string for each project (where you removed then added the Local SQL Server) must be uncommented. Remember that you will have 1 combined membership database being used for all your different projects now so you normally only need the 1 administrator account for all of them. So, again, to update the membership data (roles, users, etc) for your GoDaddy database, rather than your local membership database, you should be sure that your web config has the Local SQL Server removed, then added back in with the GoDaddy connection string. (If those lines of code are commented out, then you re going to be working with your local membership database). THEN, go the WSAT tool from the Solution Explorer to administer your roles and/or users. v20130920e GoDaddy Data Driven Web Application Deployment page 6