Deployment of Web applications in ASP. net2.0

Source: Internet
Author: User
Tags ftp site
After creating a web application, we need to consider how to deploy and release it. In general, try to simplify the installation so that users can have a very good user experience. However, in some cases, you may have high requirements on the installation program. For example, you may need to write some installation configuration information to the Registry. How can I install and deploy a web application? This is somewhat different from installing and deploying an application under a common winform. In the past, it was always very difficult to install and deploy Web applications, but since ASP. from NET 1.1 until now ASP.. NET 2.0, it is very easy to install and deploy Web applications. This article focuses on how to use Visual Studio. NET express beta/Visual Studio 2.0 to install and deploy Web applications under ASP. NET 2005.
  
First, let's take a look at what Web applications generally include. A Web application generally includes a web page (. aspx files and HTML files), various configuration files (such as web. config), various related resource files, as well as various source code files including Core Business Code, these files are generally placed in a virtual directory of the Web server. Because ASP. NET adopts the compiling architecture, it also includes various DLL files after compilation, which are placed in the bin directory. For deploying web applications, you can use the following methods in. NET 2.0:
  
1. Use xcopy for deployment
  
2. Deploy the copy web site function of Visual Studio
  
3. Use precompilation pre-compilation and deployment of Visual Studio
  
The following three methods are described respectively:
  
   Use xcopy for deployment
  
First, use Visual Studio express to create a web site, select VB. NET or C #, and then create an application named deployment. In this application, because our purpose is to focus on installation and deployment, you can pull a button and then in The onclick event of this button, write some screen output statements.
After the program is compiled, we start to use xcopy to deploy the application. Xcopy is the simplest method for. NET application deployment. Xcopy simply copies all files of your web application to a specified path on the target server. For example, run the following command:
Xcopy D: \ intetpub \ wwwroot \ myprojects \ developer \ deployment c: \ Temp/e/k/R/O/h/I
  
After the execution, the result is as follows: all files of the current application deployment will be copied to the temp directory of drive C. Then, create a virtual directory in IIS and point to the directory. For how to use xcopy, refer to the relevant Command help.
   
  
    Use the copy web site function of Visual Studio for deployment
  
Visual Studio's copy web site function allows us to conveniently deploy and install Web applications. By using this function, you can copy a web project to the same server, other servers, or FTP. However, when using this function, you only need to copy the file to the destination path without executing any compilation operations.
In Visual Studio Express, select copy web site from the web-site menu. The following dialog box is displayed:
   
The left part is the source web sites and the right part is the target path to be deployed. Pay attention to the drop-down selection box under move files on the right, which provides three file replication methods for you to choose from:
  
1. All source web files to remote web site (all web files are copied to remote web sites)
  
2. All remote web files to source web site (all remote web site files are copied to the local site)
  
3. Synchronize source and remote web sites (Synchronize files of local and remote web sites ).
  
Click connecting... The following dialog box appears:
   
Here, you can select where your local web application is copied, such as file system (local file system), local IIS (local IIS server), and FTP site, or remote site. After selecting the target path, you can click the "Copy web site" button. The system automatically copies the files of the application system to the target path and displays the copied logs.
  
   Use precompilation pre-compilation and deployment of Visual Studio
  
ASP. A new feature in net 2.0 is dynamic compilation, which allows you to directly access the webpage after editing or saving the modified webpage, without re-compiling, however, this has a disadvantage. The compilation process will lead to the first request to ASP. the response speed of the net page is slower than that of subsequent requests, while. in NET 2.0, precompiling is also provided. With this function, the results can be immediately displayed to the first user, any errors on the ASPX page can be detected during the batch compilation process. However, batch compilation does extend the application startup time and must be embedded in the web. config file.
  
ASP. NET 2.0 pre-compilation can be divided into two types. The first type is in-place compilation. You only need to enter http: // site name/webapp name/precompile in the browser. axd, the system will compile all the pages in the webapp first, after running, as shown in:
  
ASP. NET 2.0 provides an update compilation and deployment method called precompilation deployment ). Net Framework 2.0compile a command line tool (aspnet_compiler.exe), which can compile all the code, pages (including HTML), and static files in the webapp into the DLL, and then deploy and obtain the target system, only the compiled DLL is included, and even HTML page files do not exist. This greatly enhances the security of the system, but browsing is similar to common ASP. NET applications. The usage is as follows:
  
Aspnet_compiler.exe can be found in the. NET Framework 2.0 subdirectory under the WINNT directory in the following format:
  
Aspnet_compiler-V/<websitename>-P <source> <destination>
  
Specifically, websitename is the virtual directory name of the Web application to be deployed, and <source> is the physical path of the Web application to be deployed, <destination> is the physical path of the application to be deployed, for example:
  
Aspnet_compiler-V/deployment
-P c: \ Inetpub \ wwwroot \ myprojects \ developer \ deployment c: \ compiled
  
All files will be pre-compiled to the compiled directory of drive C. In this directory, you will find that there are no code files or HTML files.
  
   Summary
  
This article briefly introduces three web application deployment methods in ASP. NET 2.0 and introduces their respective features. For more in-depth discussions on deployment and installation in. NET 2.0, refer to msdn.
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.