80 likes | 147 Views
Moving & Copying Web Applications. Why Do We Need to Copy or Move a Web Application?. So you can run someone else’s sample code. So you can backup your work and restore from those backups. So you can deploy your development code to a production server.
E N D
Why Do We Need to Copy or Move a Web Application? • So you can run someone else’s sample code. • So you can backup your work and restore from those backups. • So you can deploy your development code to a production server.
How to Copy a Web App (3 steps)1. Create new Web App • Suppose you wanted to spin off a copy of one web app, making two web apps that both run on your machine. This might be useful if you have a working web application and you want to try something dangerous on a copy. • Suppose the source app is named SampleApp and you want to make a copy called MyApp. • In Visual Studio, create a new web app called MyApp. • In the Solution Explorer Window, right click on “MyApp” (under “solution MyApp”) and select “Add – Existing Item”. Or you could select Project – Add – Existing Item from the menu.
How to Copy a Web App (3 steps)2. Add Existing Files • In the File Open Dialog box, navigate to the folder where you unzipped the original files. Select “all files” from the File Type dropdown list. • Using the Control or Shift key, select 3 files for each webform you are trying to copy in. Select every “.cs” file for every class you are trying to copy in. If you need a folder (such as “images”), select that too. • Do not select these things: files that have .csproj in their name (there would be several starting with “SampleApp”), folders such as “bin”, files that start with “Global” or “AssemblyInfo” or “Webconfig”. • Click Open. Then click Yes – Replace all files. • When you get the warning that says “files have been modified outside of Visual Studio – do you want to reload”. Answer “yes”.
How to Copy a Web App (3 steps)3. Set Start Page, Search/Replace • In the Solution Explorer window, right click on the webform that should be the start page. (By default Visual Studio assumes that WebForm1 is the start page.) • You need to do a global search and replace (whole project) and change “SampleApp” to “MyApp”. • There will be MANY places changed. It’s somewhat interesting to see all the places it’s stored – this is one of the reasons why you just can’t move these files around and still be able to run them. Another reason is that when you create a new web application, Visual Studio registers that web application on your machine (& this is also necessary for the application to run). • Press F5 and your app should run.
How to Move a WebApp (1 of 3) (Create new Web App) • Suppose you wanted to install sample code that someone else is giving you (for example sample code from doc sharing). • Suppose the sample code is stored in Sample.zip. • Extract all the files of Sample.zip, say, to your desktop. • In Visual Studio, create a new web app called Sample (use the same name as the source project). • Select Project – Add – Existing Item from the menu.
How to Move a WebApp (2 of 3)(Add Existing Files) • In the File Open Dialog box, navigate to the folder where you unzipped the original files. Select “all files” from the File Type dropdown list. • Using the Control or Shift key, select 3 files for each webform you are trying to copy in. Select every “.cs” file for every class you are trying to copy in. If you need a folder (such as “images”), select that too. • Do not select these things: files that have .csproj in their name (there would be several starting with “SampleApp”), folders such as “bin”, files that start with “Global” or “AssemblyInfo” or “Webconfig”. • Click Open. Then click Yes – Replace all files. • When you get the warning that says “files have been modified outside of Visual Studio – do you want to reload”. Answer “yes” to this.
How to Move a WebApp (3 of 3)(Set Start Page, no Search/Replace) • In the Solution Explorer window, right click on the webform that should be the start page. (By default it will think that WebForm1 is the start page.) • Because you named your new project the same as the sample project, you don’t need to do a global search and replace (on the whole project) to change the project name. • Press F5 and your app should run.