Windows ServerでASP.NET Core アプリを公開するためのIISの設定手順を紹介します。
【検証環境】Windows Server2019 / IIS10.0 / ASP.Net Core 3.1
サーバーの準備
本稿ではさくらのVPS for Windows Server を利用します。(検証用のため、最安のW1Gプラン)
2週間トライアル無料のため、期間中に解約すれば料金はかかりません。
IISのインストール
①サーバーマネージャーから、役割と機能の追加を選択
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS_1-1024x545.png)
②<開始する前に> – 次へ
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS_2-1024x725.png)
③<インストールの種類の選択> – 役割ベースまたは機能ベースのインストールを選択した状態で次へ
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS_3-1024x724.png)
④<対象サーバーの選択> – 対象サーバを選択して次へ
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS_4-1024x727.png)
⑤<サーバーの役割の選択> – Webサーバー(IIS)を選択して次へ
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS_5-1024x732.png)
⑥機能の追加をする
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS_6-1024x731.png)
⑦<機能> – ASP.NET 4.7 を選択して次へ
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS_8-1024x724.png)
⑧<Webサーバーの役割(IIS)> – 次へ
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS_9-1024x725.png)
⑨<役割サービスの選択> – デフォルトの状態で次へ
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS_10-1024x727.png)
⑩<確認> – インストール
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS11-1024x729.png)
インストールが完了すると、サーバーマネージャーにIISが表示されるようになります。
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS12-1024x543.png)
ツールのインストール
下記リンクより各インストーラーをダウンロードします。
・.NET Core SDK x64
・.NET Core Runtime(Hosting Bundle)
ダウンロードしたインストーラーを実行してインストールを完了します。
https://dotnet.microsoft.com/download#windowscmd
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS13-1024x403.png)
ダウンロードしようとすると下記のようなポップアップが表示されました。
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS14.png)
VPSのIEの初期設定でダウンロードが無効になっていました。
下記の通り設定を変更する必要があるようです。
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS15-752x1024.png)
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS16-771x1024.png)
IISの設定
スタートメニューからインターネットインフォメーションサービス(IIS)マネージャーを選択
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS18-1024x576.png)
アプリケーションプールを右クリックして、アプリケーションプールの追加を選択
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS19-1024x535.png)
任意のアプリケーションプール名を入力
.Net CLR バージョンでマネージコードなしを選択してOK
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/%E3%82%AD%E3%83%A3%E3%83%97%E3%83%81%E3%83%A3.png)
サイトを右クリックしてWebサイトの追加を選択
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS21-1024x534.png)
任意のサイト名を入力
物理パスにはあらかじめ作成していたアプリケーションを格納するフォルダを指定
※本稿ではEドライブを作成してフォルダを作成しました。(パーティションの作成手順などは割愛します)
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS22-1024x576.png)
はいでOK
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/%E3%82%AD%E3%83%A3%E3%83%97%E3%83%81%E3%83%A32.png)
Webサイトの管理から、Default Web Site を停止させ、追加したサイトを開始
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/IIS24-2-1024x537.png)
アプリケーションのデプロイ
発行したアプリケーションをIISの物理パスで指定したフォルダにデプロイします。
ブラウザでIPを指定して開くとアプリケーションが動作することが確認できました。
![](https://web.archive.org/web/20220519082921im_/https://pg-life.net/wp-content/uploads/2021/06/%E3%82%AD%E3%83%A3%E3%83%97%E3%83%81%E3%83%A33-1024x564.png)