Deploy Asp. Net Core App and asp. netcore in Windows and IIS
Environment: Windows Server 2012, IIS 8, Asp. Net Core 1.1.
Many people who deploy Asp. Net Core App in IIS for the first time will encounter problems. They will find that Asp. Net Core App cannot run in the original deployment mode. In the past, no matter the original Asp program or the Later Asp. the deployment method of the. Net Program in IIS has not changed much. You only need to point to the program directory, set the virtual directory, and configure some parameters. Asp. net Core App to achieve cross-platform, comes with a lightweight Web Server-Kestrel, so you need to deploy Asp in IIS. net Core App, there must be a new mechanism to coordinate data transmission between IIS and Kestrel Server.
1. deployment mode of Asp. Net Core
Unlike traditional Asp. Net programs, Asp. Net Core apps use Kestrel Server. Kestrel is a cross-platform Web Server that monitors, receives, and responds to requests like IIS. However, without the rich management functions of IIS, IIS still needs to handle some front-end work. (You can also use Apache for pre-processing)
IIS forwards external requests to the backend Asp.net Core App and acts as a "reverse-proxy.
2. Understanding reverse proxy
"Reverse" refers to the inbound traffic. "proxy" can be understood as a service, which forwards HTTP requests. "Reverse proxy" is the service that forwards HTTP requests to the inbound network.
Similar to the principle of a router, in addition to enabling the LAN to access the internet, a vro can also set NAT or port ing to access an internal server from the internet, it is equivalent to forwarding an inbound request to a specified computer, which is similar to the reverse proxy role of IIS. Both the proxy server and vro play the role of data forwarding, but the proxy server forwards data of a certain type of applications, and the vro forwards data packets.
3. Deployment Environment
The deployment of Asp. Net Core APPs must meet the following requirements:
- Windows 7 or later
- Windows Server 2008 R2 or later
4. Configure IIS
On Windows Server, you can install and configure IIS through "add roles and functions" and "enable and Disable Windows functions" on desktop Windows. Make sure to check the Web service and "IIS console ":
Install and configure IIS on Windows Server
Installation and configuration of IIS for desktop Windows
5. Install the. NET Core Windows Server Hosting assembly
Install the. NET Core Windows Server Hosting Assembly to enable the reverse proxy function for IIS. This Assembly contains the. Net Core Runtime,. Net Core Library, and Asp. Net Core Module. Asp. Net Core Module is responsible for reverse proxy. Note: For offline installation, you must manually install Microsoft Visual C ++ 2015 Redistributable.
Note that currently.. NET Core version is upgraded quickly. Please download the latest version. NET Core Windows Server Hosting to ensure that. the. Net Core version is no lower than the deployed Asp.. Net Core App version.
Download the latest. NET Core Windows Server Hosting version.
After installation, restart the system or restart the IIS service.
6. Configure Asp. Net Core App in IIS
The next steps are basically the same as deploying a traditional website, but they are slightly different. Please note.
1) create a directory on the server to store the published App files, and ensure that the web. config file of the App is under the root directory of the website.
2) create a logs folder in the root directory of the website. If you have enabled some log services, log files will be recorded here. Of course, no logs can be recorded, but the initial deployment is helpful for troubleshooting. We recommend that you create one.
3) Add a website in the IIS manager. The steps are consistent with the general website Configuration:
4) configure the application pool. In the left-side Navigation Pane, select "application pool", select the specified application pool, right-click the menu, and select "Basic settings" To set. Net CLR version to "unmanaged code ".
7. Test Asp. Net Core App
In this example, we use a public network domain name www.test.com. Obviously we have no permission to change the domain name's resolution record on the public network, but we can change the domain name's local point for testing. Use NotePad to open the C: \ Windows \ System32 \ Drivers \ etc \ hosts file and add a record "127.0.0.1 www.test.com ". When we access the domain name www.test.com locally, the IP address will be resolved to 127.0.0.1. Open www.test.com in a browser and we will see that the Asp. Net Core App is running properly:
Read more: Deployment fault examples of Asp. Net Core apps |