Deploying the. Net core webapi application in IIS

Time:2021-11-27

Environmental description

This article demonstrates how to deploy net core, write webapi and deploy it as an IIS site. The demonstration environment is as follows:

  • Visual Studio 2019(v16.8)  download
  • .Net Core 3.1 download
  • A device with IIS installed, in theory

Note:. Net core 3.0 project development requires vs2019 (v16.3 and above) support

Project creation

The following is a simple demonstration of the creation of a. Net core webapi project

  1. Open vs 2019, add a new project, selectAsp.net core web application, click next
    image
  2. Enter the project name and click create
    image
  3. Select API, runtimeASP.NET Core 3.1, and then click create
    image
  4. Directly press F5 to generate and run. See the default interface output in the browser. The project is created
    image

Project release

  1. In VS, select the item just created and right-click to selectrelease, enter the publishing interface, select a folder, and then click next.
    image
  2. Set the location of the published document, and then click finish
    image
  3. Enter the file publishing window, modify runtime and other information, and click the pencil icon to modify runtime and other information.
    image
  4. Deployment mode selection depends on the framework, and target runtime selectionwin-x64, click save
  5. Enter the publish interface and click publish
    image
  6. Wait for publishing to complete and enter the publishing file directory.
    image

Project deployment

  1. Enter the deployment server and ensure that IIS is installed on the server
  2. Download and install the. Net core 3.1. X runtime(Hosting bundle installation package), continue to the next step until the installation is complete
    imageimage
  3. To deploy. Net core applications in IIS, you need to add an application pool separately and select the. Net CLR versionNo managed code, IIS is just a reverse proxy for deploying. Net core programs.
    image
  4. After creation, add a new site in IIS, and the application pool uses the unmanaged code application pool just created.
    image
  5. Browse the website and verify the published results.
    image

Note: find the web.config file in the publishing directory, open it and stdoutLogEnabledChange the option totrue, you can enable logging

image

image

Finally, the support of each version of. Net core in the operating system is attached

image