Microsoft ASP. NET site deployment guide (7): Production Environment deployment

Source: Internet
Author: User

 

1. Summary

Now, the program has been deployed in the local IIS and tested. It is time to publish the program to the Internet. In this section, you will create a VM account and publish the program to the production environment.

Reminder: check the Troubleshooting page if an error message or some functions are abnormal during operations in this section.

2. Select a host provider

For the Contoso University Program and this series of tutorials, You need to select a virtual host that supports ASP. NET 4 and Web Deploy. We chose a host provider to demonstrate a complete deployment experience. Since different providers provide different functions and deployment processes, the deployment process in this tutorial basically covers all the steps. This tutorial uses Cytanium.com, which does not mean it is recognized and recommended.

If you want to select a provider, you can compare the functions and prices supported by the provider list on the Microsoft Site.

3. Create an account

Create an account at the provider. If the full version is supported, we do not need to use this chapter. However, the subsequent sections will show you how to migrate data to the full SQL Server.

In this tutorial, you do not need to register a new domain name. You can directly use an existing domain name or use a temporary URL provided by the provider to access the domain name.

 

After an account is created, you will usually receive a welcome email containing all the information for deploying and managing the site. The content of emails sent by different providers is different, but they are similar. Emails sent by Cytanium generally include the following information:

  1. The URL of the control panel, which allows you to manage site configuration information. The account and password are also included (you do not have to try to log in later ).

  2. The default. NET Framework Version and how to modify the version information. Most VM sites provide version 2.0 (supports 2.0/3.0/3.5 programs), but Contoso University is a Program Based on. NET Framework 4, so you need to modify this setting later.

  3. The temporary URL address of the website, which is entered at the time of creation and the existing domain name (contosouniversity.com ). Therefore, the temporary address is: http://contosouniversity.com.vserver01.cytaniu.com.

  4. How to Create a database and set the connection string information:

  5. Tools and settings required for deploying a program (WebMatrix information is also mentioned, which is ignored here ).

 

4. Set the. Net Framework Version

The Cytanium welcome email contains a connection that can change the. NET Framework version. This page describes how to set it through the Cytanium control panel. The control panel of other providers may be different and may be operated in other ways.

 

Access Control Panel address. after entering the user name and password, you will see the following page:

 

InHosting SpacesIn the box, move the mouse up to see the two connections, selectWeb Sites.

 

InWeb SitesIn the dialog box, click contosouniversity.com (name entered during Account creation ).

 

InWeb Site PropertiesBox, selectExtensionsTab:

 

Extract ASP. NET from2.0 Integrated PipelineModify4.0 (Integrated Pipeline)And then click Update.Update.

5. Publish a program to a VM

Modify the current build configuration to Release. You can select from the toolbar (for example) or (Build)In the menuConfiguration Manager(Configuration Manager.

 

Solution ExplorerRight-click the ContosoUniversity project and select publish (Publish).Publish WebThe Test profile is displayed in the dialog box, because you have created only this one so far.

InPublish profileIn the dialog box, select new:

 

Enter the new name "Production"

InService URLEnter the address provided in the welcome email from the provider.

InSite/applicationEnter the name provided in the welcome email from the provider.

SelectMark as IIS application on destination.

Make sure you selectLeave extra files on destination (do not delete)If you do not select this Web Deploy, the files that are not found in the solution on the target site will be deleted. The first deployment will not be affected, but the subsequent upgrade deployment will be miserable, select it to avoid these problems. For example, it will delete the log files in the Elmah folder of the production environment (not in your solution ).

SelectAllow untrusted certificate.

Enter the authentication account information provided by the provider

SelectSave passwordSo that you do not need to enter the password every time.

 

Click to publish (Publish)

In this way, the program is published to the VM, and the Output window displays the publishing result.

 

6. Set Elmah Directory Permissions

Remember to set the write permission when logging Elmah in the previous chapter to write the XML file. You need to set it manually when deploying it on your local IIS. In this section, you will use Cytanium to set this (other providers do not allow this. Generally, they will provide special directories for you to write files. In this case, you have to modify your program to write files in a special directory ).

You can set permissions in the Cytanium control panel, access control panel URL, and then selectFile Manager.

 

File ManagerSelectContosouniversity.com, You can see the root directoryWwwrooot. ClickElmahClose the lock image on the right.

 

InFile/Folder PermissionsIn the windowContosouniversity.comSelectReadAndWrite, Click Save (Set Permissions).

 

7. Set Bin directory permissions

For Cytanium and SQL Server Compact, you need to pay attention to another folder permission issue. If you run the program, the home page is OK, however, the following error occurs on other pages that involve database operations:

System.UnauthorizedAccessException : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

The reason is that to read the native assembly, the network service account will read the Assembly from the bin directory, but it does not have the permission now. (If you want to see this error message, you need to modify the Web. the config error is set to Off and re-deployed, because the custom error page is displayed in the default production environment, and you cannot find the error message on the error report page, it is because you have no permission to write this error message .)

Open againFile ManagerInWwwrootClick "Close Lock image" in the bin directory.File Folder PermissionsIn the pop-up windowContosouniversity.com and NETWORK SERVICESelectRead. Then selectReplace permissions on all child objectsClickSet PermissionsSave settings.

 

8. test the product environment

Open the temporary access address (in this example: http://contosouniversity.com.vserver01.cytanium.com) given when creating an account, you can see the same effect as the home page in your local Visual Studio, but no longer show the Test and Dev indicators, this means Web. the information after config transformation is correct.

 

Access the Students Page to verify that the database has no student record:

 

Visit the Instructors page to verify that the Instructors data is still in the database:

 

Like the test environment, you need to verify whether the database in the production environment can operate normally, but you usually do not want to input the test data because it is a real production environment. This section uses the same method for testing.Real Production EnvironmentYou need to do this in different ways, such as the way to verify without entering the test data. Of course, you can also add some practical data for testing and then delete it.

 

Add a student and visit the Students Page to check whether the data exists to verify whether the database operation is normal:

 

SlaveCoursesMenu selectionUpdate CreditsPage to verify that the authorization authentication is normal. Normally displayedLog InPage.

 

After entering the Administrator account and password to log on,Update Credits pageIt can be displayed normally, indicating that the ASP. NET membership database works normally.

 

Test whether Elmah normally records logs when producing error logs and accesses an invalid URL address (for exampleStudentsxxx. aspx). As before, the GenericErrorPage. aspx page is displayed. ClickLog OutExit the connection, run Elmah. axd, and display againLog InPage (verifiedWeb. configIs the Elmah-certified transform correct?) after logging on, you can see the error message generated just now.

 

Now that the site has been successfully deployed and the test results have been verified, the site can be officially run on the public network.

9. Create a more reliable test environment

In Chapter 5th, we mentioned that the most reliable test method is to purchase 2nd accounts from the host provider as the test environment, which is naturally higher than testing IIS on your local machine, however, to prevent problems in the production environment, it is only worthwhile to purchase 2nd accounts for testing.

The procedure for deploying a test account is almost the same as that for deploying a production environment. You only need to do the following:

  1. Create a new build configuration and Web. config transformation file by referring to chapter 3rd and Chapter 4th.
  2. Like the production environment deployed above, you can purchase another account from the host provider to deploy this new build configuration.
  3. Create a new publish profile to deploy it to this test account.
10. Prevent the test site from being published

To test the account, you should consider that it runs on the public network, but you do not want others to access it. If you want to save the website private, you can do this:

  1. Contact the host provider to Set firewall rules for you so that only your IP address can access the test.
  2. Conceal URL paths so that URLs in different production environments are similar.
  3. UseRobots.txtDisable search engine crawling to include your address.

 

1st calls are the most common, but the process processed by each provider is not written here. If your provider can set to only allow your IP address in the house, in theory, you don't have to worry about crawling the search engine.Robots.txtJust in case.

The deployed robots.txt should be as follows:

User-agent: * Disallow: /

 

User-agentTell the search engine that the following rules apply to all search engine crawlers,DisallowThis means that crawlers are not allowed to access all pages.

 

The production environment must be included, so do not deploy this file. Reference: Can I exclude specific files or folders from deployment? To ensure that onlyReleaseExclude this file in build.

 

Although it is not necessary to create a second virtual host account for the test environment, it is very worthwhile. The following sections use IIS as the test environment.

In the next section, modify the program and redeploy it to the test environment and production environment.

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.