How to: Prepare to Deploy a Web Project
Before you deploy or redeploy a Web project, you might want to prevent the production site from responding to page requests during the deployment process. This can help avoid errors that might result during the time when the changes are only partially completed. Also, when changes occur to some file types and folders, the application domain restarts, and you might want to make sure that this does not happen multiple times.
To take a Web application offline before deployment
- Create a file called App_offline.htm and include a message in the file that lets users know that the site is unavailable because you are updating the site.
- Place the App_offline.htm file in the root folder of the target Web site.While the App_offline.htm file exists in the root of your Web site, any request to the Web site will redirect to that file.When you have finished deploying the site, remove the App_offline.htm file.
Basic Deployment Tasks
Here are the basic tasks that you have to do in order to deploy to a third-party hosting company:
- Set up an account with a hosting company.For information about hosting providers that support automated deployment from Visual Studio, see ASP.NET Hosting. Make sure that you choose a provider that supports the version of ASP.NET that your web project targets.
- Create a publish profile.A publish profile specifies the server you are deploying to, credentials for logging on to the server, databases to deploy, and other options. The hosting company sends you the settings you need for the publish profile, either in an email or in a file that you can import into Visual Studio.
- Start the deployment process by clicking the one-click publish button. The Publish button is in the Publish Web wizard that you use to create publish profiles. It is also available in the Web One Click Publish toolbar that you can choose from the View–Toolbars menu in Visual Studio.
How to make an Website Offline:
- Create a file called App_Offline.htm
- Insert a offline message you want to display while the website is offline
- Upload that file into the webhost root folder
- If the App_Offline.htm file is present website automatically redirect it to this file
- To make the Website online again just remove the App_offline.htm file.
Taking an Application Offline before Publishing
In Web Deploy V3, we added support to automatically take an ASP.Net application offline before publishing to it. This is useful if a user wants to ensure that their application does not have a lock on a file (e.g. SQL CE sdf files which only allow one connection to the file at a time) being overwritten, or if they want to ensure that visitors to their site cannot affect the publish process. The way it works is if Web Deploy detects that a change needs to be made on the destination server, it will automatically drop a blank App_Offline.htm file into the root of the application folder. When ASP.Net detects that a file by the name of "App_Offline.htm" exists, it will automatically bring down the app domain hosting the application. When the publish process is completed, the App_Offline.htm file will be removed and the site will be online again.
- Enabling Application Offline
Web Deploy takes an application offline by using the "AppOffline" rule, which is off by default. If a client wishes to turn it on during a publish operation, it simply needs to enable the rule. Here is an example of how to do this from the command line (executable lives under "%programfiles%\IIS\Microsoft Web Deploy V3"):
msdeploy.exe -verb:sync -source:iisApp=mySite -dest:auto,computername=<publishUrl> -enableRule:AppOffline
- What happens when a publish fails
If an error occurred during publishing, the htm file will remain in the site root to keep it offline because it is now in an unknown state. After fixing your publishing issue, you will need to bring the application back online. To do this, you can either manually delete the App_Offline.htm file from your application root on the server, or republish your site. Here is an example of how to delete the App_Offline.htm file from the command line:
msdeploy.exe -verb:delete -dest:contentPath=siteName/App_Offline.htm,computername=<publishUrl>
Precompiling for Deployment Only
When you precompile for deployment only, the compiler produces assemblies from virtually all ASP.NET source files that are normally compiled at run time. This includes program code in pages, .cs and .vb class files, other code files, and resource files. The compiler removes all source and markup from the output. In the resulting layout, compiled files are generated for each of the .aspx files (with the extension .compiled) that contain pointers to the appropriate assembly for that page.
To change the Web site, including the layout of pages, you must change the original files, recompile the site, and redeploy the layout. The only exception is the site configuration; you may make changes to the Web.config file on the production server without having to recompile the site.
This option provides the greatest degree of protection for your pages and the best performance at startup.
How to Create an Offline Web Page
Web designers commonly have a need to build pages when offline in order to continue work when an Internet connection is not available. By working on a website offline, you can test new concepts prior to going live on the Internet, thereby avoiding any loss of web traffic. Additionally, an offline website provides a full backup of your website in the event of catastrophic failure with the copy saved on your web server. Have a question? Get an answer from Online Tech Support now!
Instructions
- 1Create a directory structure on your computer that is identical to your web server. To do this, create a folder on your computer named "MyWebsite". Then, open the "MyWebsite" folder and create the first level of sub-folders that exist on your website, such as "mycontent" and "images". To create a new folder, right-click in the white space of the folder, left-click "New Folder" and type the name of the website in the text field.
- 2Save copies of all of the images on your website to the "Images" folder located under the "MyWebsite" folder created in step 1.
- 3Change the hyperlinks of the images in your web pages to be directed to the local folder. For example, where your previous image link URLs would be similar to: "http://www.mywebsite.com/images/myimage.jpg", the new URL's will be of the form: "images/myimage.jpg".
- 4View the offline website in your web browser by using your browser's file chooser to open the "Index.html" page, or manually enter the following URL convention in your browser's toolbar:
"file:///c:/MyWebsite/Index.html".
- 1
Publishing a Visual Studio Project (Not Website):
To access this tab on the Properties page
- In Visual Studio, open a web application project.
- In Solution Explorer, open the shortcut menu and choose Properties (C#) or MyProject (Visual Basic) to display the Properties page.
Choose the Package/Publish Web tab.
Note:
- Create a Web Deployment Package in Visual Studio
No comments:
Post a Comment