# 22.1、IIS 托管部署

## 服务器环境配置

1. 安装.NET Core运行时捆绑包：[点击下载](https://dotnet.microsoft.com/permalink/dotnetcore-current-windows-runtime-bundle-installer)
2. 安装好后 **重启服务器** 或者 直接执行 `cmd`（管理员模式） 命令：

### 1） 第一步（**如果重启电脑就不需要执行命令了**）

```
net stop was /y
```

### 2） 第二步（**如果重启电脑就不需要执行命令了**）

```
net start w3svc
```

### 3）第三步（打开命令行设置环境变量）

```
set ASPNETCORE_ENVIRONMENT=Production
```

## Visual Studio 上发布网站

### 1）选择 `Hoa.Web.Hoa` 项目，右键点击发布

![](/files/-MA04EVDKtdbmZzuOCdt)

### 2）选择发布到文件夹

![](/files/-MA04I8xZbpXYuGk9_kL)

### 3）选择发布后文件夹和点击完成

![](/files/-MA04N5vCHFWojgZWJpj)

### 4）点击发布

![](/files/-MA04QZdrbQyze9vkBSy)

## 部署到服务器中

### 1）选择 `Sites`，右键添加新网站

![](/files/-MA04mVSlzcEtKELonCZ)

### 2）填写 `网站名称`，`发布的路径`，`端口`

![](/files/-MA04sSf9-I0H7wg8aMP)

### 3）选择 `Application Pools`，找到对应的 `网站名称`，修改 `基本配置`，设置

![](/files/-MA04wwTaFZN8yN36lug)

### 4）设置 `.NET Framework Version` 为 **No Managed Code**

![](/files/-MA05-PWQgnN9gxFDoGV)

### 5）重启网站即可

## 注意事项

**已经发布过的网站再发布，直接替换发布文件夹内容即可。**


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://monksoul.gitbook.io/hoa/tuoguanbushu/iistuoguanbushu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
