ASP. NET Website deployment part.1 (install IIS and copy files to deploy websites)

Source: Internet
Author: User
ArticleDirectory
    • Install and configure IIS
    • Install IIS
    • Manage IIS
    • Deploy website
    • Deploy by copying files

The basic prerequisites for all website deployment are the same. If a website has been deployed on the Development workstation, You need to deploy it on a server to allow customers to access it. For ASP. NET, the scenario here is IIS (Internet information services, Internet Information Services ).

At the beginning, IIS was just a basic web server. After years of evolution, IIS has been developed successfully to provide a wide range of advanced applications.ProgramServer. One of the most critical functions is to support the host ASP. NET application.

 

Install and configure IIS

Here, we turn those machines running IIS into servers, but you can also run IIS on workstation or server version windows.If possible, Windows Server is recommended, but Windows 7 or Vista is a low-cost option.

 

Install IIS

We will not go into details about how to install it here. In short, each server can support multiple sites, and each site runs on different ports or IP addresses. Each site can have multiple files and directories, and their combinations provide URL Information.

 

Manage IIS

Enter inetmgr in the Windows operating system to quickly open the IIS Manager interface.. As shown in, the left side of IIS manager is the server name, which is my local name PC-SKYSOOT and clicking that name will see the Server View.

 

Deploy website

In the simplest case, you just need to copy the directory structure of the application to the target machine and configure the environment. Nothing else needs to be done. For simple applications, this is almost enough. However, if an application uses a database or accesses other resources, additional steps are required.

The following are common factors that require additional configuration steps:

    • copy all necessary application files to the target machine. However, if you use a global assembly accessed through GAC (Global Assembly Cache) , you also need to verify that these sets are in place. If not, you must use the. NET Framework command line tool gacutil.exe for installation.
    • Create and configure databases for applications. In addition to creating a database and its tables, it is also important to configure the login and database users of the database server. Do not forget, If you connect to the SQL Server database through integrated verification, Asp. net execution account (application pool account or aspnet_wp.exe account) configured as the user of the application database . Web deployment can simplify database deployment (as will be discussed later). If you do not use web deployment, you must manually configure and populate the database data.
    • Configure IIS as required by the application. For example, create a required application pool, share the application directory as a virtual directory, and correctly configure the virtual directory.
    • set Windows Account permissions for Working Process users. You must be able to access the application directory . If an application accesses other resources, such as the registry or event log, you also need to configure permissions for these resources for the working process account.
    • If the file extension of the URL to be processed is different from that registered by the default ASP. NET installation, you need to add IIS File ing.
    • Configure the Web. config file to configure ASP. NET for the production environment (and the location specific to the IIS 7.0 application ). That is to say, correctly add (or modify) All connection strings, application settings, security and authorization settings, session Status settings, global settings, and so on.
    • sometimes you need to modify machine. config. If the web host environment is used and the application runs on multiple Web servers to support load balancing, all encryption keys used to encrypt Form Verification tickets or view status must be synchronized between all these machines . These keys are stored in machine. config and must be kept the same on all machines in the Web farm so that a machine can decrypt the encrypted information of the server that processed the request.

 

Deploy by copying files

The simplest way to deploy a website is to copy the files on the Development workstation to the server. Although simple, this method does require direct access to the server, which is precisely why some IT departments and host companies do not support this method.

 

1. Prepare IIS

Before deploying a website, you must prepare IIS. The main decision point is where to place the content and how it affects the final URL. Assume that the expected example URL is (http: <servername>: 80/websitedeployment/filecopy). We need to prepare IIS for local file replication. Open the default IIS website directory, usually the (C: \) Inetpub \ wwwroot directory. Create a directory named websitedeployment and create another filecopy directory. (The current directory is c: \ Inetpub \ wwwroot \ websitedeployment \ filecopy), refresh and find the new directory.

 

2. Website

A simple website is created to demonstrate the deployment technology. This webpage only contains one tag to display the. NET Framework Version Used by the host Website:

UsingSystem;

 
 

Public Partial Class_ Default: system. Web. UI. Page

{

Protected VoidPage_load (ObjectSender, eventargs E)

{

 
// Environment class: provides information about the current environment and platform and methods for operating them.

// Version: describes the main version, minor version, internal version, and revision number of the public language runtime.

// Major: obtains the value of the major version number of the current system. Version object.

Label1.text = system. environment. version. Major. tostring ();

 
}

}

 

3. Deploy the website

Copy the webpage to the previously created directory. This is the most important part of this deployment technology: creating a directory structure that represents the URL format you need and copying website files to the target location. View the URL to see the expected result:

Http: // localhost/websitedeployment/filecopy/default. aspx

Localhost is a special name pointing to the current machine, and the URL does not need to specify a port number for port 80. For these two reasons, pointing to the following URL will get the same page:

Http: // 20121103-1759: 80/websitedeployment/filecopy/default. aspx

 

4. Configure and deploy

You may notice that the. NET Framework version number reported during browsing is 2. This is a problem for websites that depend on ASP. NET 4. You can change the version number by setting the default application pool.

Use the IIS manager to expand the service items, click "application pool", and click "Set application pool default settings". It is displayed on the right side of the IIS manager window in the dialog box.. NET Framework Version changed to 4.0, and then re-loaded the page in the web browser. Now we can see that the version number is 4:

Sometimes, if you find that your IIS will encounter some errors, you can try to run the following command to fix those problems:

C: \ windows \ Microsoft. NET \ framework64 \ v4.0.30319 \ aspnet_regiis-I

 

We also need to tell IIS that the website we deployed is an application. This is optional, but the deployment of ASP. NET applications is almost inevitable. It enables session status and other ASP. NET functions.

In IIS manager, right-click the filecopy folder and select "convert to application ". This opens the "add application" dialog box. Click the "select" button to modify the application pool used by the application. Click "connection as" and "test connection" to configure the user account that IIS uses to access the website content. Click OK. You should find that the filecopy item already has a different icon (refresh ).

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.