Deploy three major ASP. NET technologies (I) (2)

Source: Internet
Author: User
V. Use the "Copy project" function of vs. Net to deploy

Vs. Net's "Copy project" feature allows us to easily deploy ASP. NET web applications to the target server. This function can be used to copy a web project to the same server or to different servers.

If you use. net to develop Web applications. The first thing to do before releasing a web application is to change "Active solution configuration" from debug to release, as shown in 3. This option not only enables the compiler to optimize the code, in addition, all debugging-related symbolic information is deleted to make the code run faster. To open the Configuration Manager, select "project"> "XXXX Project Properties" from "solution Resource Manager", where XXXX is the project name, click "Configuration Manager ". Select "release" in "Active solution configuration ".

Figure 3

To copy a web project to the target server, select "project"> "Copy project..." In vs. net, and the Vs. Net dialog box is displayed.

Figure 4

The copy project dialog box provides the following options:

(I) Target project folder: used to specify the target location of the duplicate project. The target location can be on the same server or a remote server.

(Ii) web access method: the method used to copy a web project to the target folder. There are two web access methods available. The first is "file sharing", that is, the file sharing mechanism is used to directly access the file system on the Web server. FrontPage Server Extensions are not required on the Web server. The second is "FrontPage ", that is, the web project files are transmitted to the server through the FrontPage Server Extension Based on the HTTP protocol. This option requires that the FrontPage Server extension must be installed on the Web server, this Web access method can automatically create necessary virtual directories on the target server.

(3) Copy: contains three options: ① only files required to run the application, that is, only files output by the "generate" function are copied (DLL and references in the bin folder) and content files (such. aspx and. asmx file). In most cases, we can use this default option to deploy the application. ② All project files, that is, the files output by the "generate" function (DLL and references in the bin folder) and all files in the project, including the project file and the source program file, ③ all files in the source project folder, that is, all project files and any other files in the project folder (or subfolders.

Select the option in Figure 4 as needed and click "OK" to deploy the WEB Project to the server.

Vi. Web-based installation project deployment

Xcopy deployment and vs. Net's "Copy function" are easy to use, but cannot meet all deployment needs. For example, if the application has more complex configuration and deployment requirements, vs. Net's "Web installation project" is the best choice.

Although we can use a lot of scripts to generate outputs, install classes, and create databases to publish Web applications, it is generally easier to use Windows Installer for complex web application projects. To support web application deployment, vs. NET provides a "Web installation project ". The Web installation project is different from the ordinary installation project. The web installation project installs the web application to the virtual root folder of the Web server, while the general installation project generally installs the application to the Program Files directory.

Vs. Net installer is based on Windows Installer, so it can take advantage of Windows installer. Before discussing the Vs. NET web installation project, let's take a look at the main features of the Windows installation program, because it is the core foundation of the Vs. NET web installation project.

6.1 Windows Installer

Windows Installer is a software installation and configuration service. Both Windows 2000 and Windows XP have Windows installer, microsoft also provides a free version with similar functions for all Windows 9x and NT 4 platforms. In Win2k/XP, the core of the Windows Installer is a Windows Installer Service. The Windows Installer Service records every application it installs. When we delete an application, windows Installer checks the installation records and ensures that other applications do not rely on these components before deleting the application components.

Windows Installer divides an application into the following three levels:

(1) Product: a unit that users can install. For example, MS word is a product that users can install.

(2) function: A product consists of multiple functions, which are the minimum unit for product use. For example, automatic correction is a function of word.

(3) component: the smallest unit that can be shared among multiple functions and components. Note that components in Windows Installer terms are different from those in. Net frameworks. A Windows Installer component is one or more logically closely related files. It can be an execution file, a DLL file, or a simple text file. A function can be provided by combining multiple components, and a component can also be shared by multiple functions. The function is always for a specific product, and the function name is only unique within a specific product range. In contrast, the component is global, it applies to all products installed on one machine. For example, the spelling check component of word can be shared among all components that want to implement the spelling check function.

Product-related information, including functions and component descriptions, is stored in an installation database. Installing a database is actually a file with the. MSI extension. It not only contains the features and components of the product, but also defines the display order of each user interface during product installation. Because Windows Installer registers a. MSI file service program, the operating system automatically calls Windows Installer when you open the. MSI file. When Windows Installer is started in this way, the installer reads the product information from the installation database and determines whether the product has been installed. If the installer is not installed yet, follow the description of the installation database to start the installation. If the product has been installed, you may perform other operations, such as adding/deleting a function or uninstalling the entire product.

6.2 vs. NET web installation project features

The deployment project in vs. NET is based on the functions of Windows Installer. You can perform the following operations:

(1) read and write registration keys.

(2) create a directory in the Windows File System of the target server.

(3) provides a mechanism for registering components.

(4) provides a mechanism to collect information from users during installation.

Allow allows you to set startup conditions, such as checking the username, computer name, current operating system, installed software, and whether. Net CLR has been installed.

Idea allows you to run custom configuration programs or scripts after the installation is complete.

In the following section, we will learn how to use the Vs. NET web installation project to deploy deploymentexamplewebapp.

7. Create a web installation project

First, deploymentexampleapp ASP. create a web installer project in the. NET web application solution: Select File> New> project. In the Create Project dialog box, specify the project type "installation and deployment project" and the template "Web Installation Project", as shown in Figure 5.

Figure 5

After creating a project, add the Assembly and content files of ASP. NET web applications to the installation project. In Solution Explorer, right-click the deploymentexamplewebappsetup project, select "add"> "project output", and select deploymentexamplewebapp in the "add project output group" dialog box, select "primary output" and "six" from the list.

Figure 6

After adding the project output, add the relevant content files (including. aspx files and graphic files) to the project. Open the "add project output group" dialog box again. This time, select "Content File" and "7" from the list.

Figure 7

After "main output" and "Content File" are added to the web installation project, solution resource manager should be shown in Class 8.

Figure 8

You can set many properties in the Properties window of the Web installation project. These properties determine the content and behavior of the Windows Installation File during running. In solution manager, right-click deploymentexamplewebappsetup and select "properties" to open the attribute setting window in Figure 9.

Figure 9

As shown in Figure 9, the attribute window allows you to set the author, product description, vendor, support phone number, and other information, which may be very useful to end users of the application.

8. Install ASP. NET web applications

Create a Windows installation file (. then install ASP on the target server. NET application is very convenient, as long as you double-click in Windows Resource Manager. the Installation Wizard starts and guides you through the installation process. Figure 10 shows the first dialog box displayed during installation.

Figure 10

Click "Next" in the figure 10 dialog box. The dialog box shown in Figure 11 appears. You can specify the virtual directory to which the web application is installed. This is one of the most convenient features of vs. NET web installation projects. virtual directory creation has been fully automated and does not require manual operations. In the second part of this article, we will see how to set special properties of the virtual directory during installation, such as Directory Security.

Figure 11

In the dialog box shown in Figure 11, click "disk overhead" to learn about the disk space required to install the web application. Click "Next". The dialog box shown in Figure 12 is displayed. The Wizard asks us to confirm the installation.

Figure 12

If you click "Next" in the dialog box in figure 12, the installation starts and the application is installed on the Web server. If the application is successfully installed, the dialog box shown in Figure 13 is displayed.

Figure 13

After the application is installed, you can see the ASP.. NET application. In the future, we can uninstall the ASP.. NET web applications.

IX. Conclusion

Xcopy and "Copy project" are both good deployment technologies. Their main features are simple, but manual operations are required. They are very suitable for applications with relatively simple installation process, but in some cases, we need to perform more complex operations during the installation process. In this case, it is best to use the Windows Installer technology to deploy the application. Deploying ASP. NET web applications with Windows Installer has the following advantages:

(1) If an application installed with Windows Installer is damaged, you can use the repair function of the Windows installation package to repair it. If other deployment methods are used, damaged components must be replaced manually.

(2) When using Windows Installer technology, we can also take advantage of the automatic rollback feature. When the installation process fails, the automatic rollback function not only ensures that the installed components are deleted correctly, but also ensures that the machine can be restored to the status before the installation program starts.

(3) Because Windows Installer uses a. MSI installation database to save all the installation information, it is possible to obtain information such as the files copied and the registration keys created.

(4) If ASP.. Net Applications must be distributed to multiple users (or packaged and sold). A convenient and automatic deployment mechanism is essential, manual operations such as xcopy deployment are obviously not suitable. If Windows Installer is a mature and powerful installation technology, the entire installation process can be automated, greatly simplifying application deployment.

This section demonstrates various methods for encapsulating and deploying ASP. NET web applications, describes how to leverage the advantages of Windows Installer technology, and the specific process of creating. MSI. In the next part of this article, we will add various advanced features based on the previous Windows Installer example, such as the customized installation dialog box and Its Appearance Order, and how to add the registration key and create a custom folder during the installation process.

Download the code in this article: deployingaspnet_code1.zip.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.