Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Tutorial ini menunjukkan cara menghosting aplikasi ASP.NET Core di server IIS.
Tutorial ini mencakup subjek berikut:
- Instal .NET Core Hosting Bundle di Windows Server.
- Buat situs IIS di Manajer IIS.
- Menyebarkan aplikasi ASP.NET Core.
Prerequisites
- .NET Core SDK diinstal pada komputer pengembangan.
- Windows Server dikonfigurasi dengan peran server Server Web (IIS). If your server isn't configured to host websites with IIS, follow the guidance in the IIS configuration section of the Host ASP.NET Core on Windows with IIS article and then return to this tutorial.
Warning
Konfigurasi IIS dan keamanan situs web melibatkan konsep yang tidak tercakup dalam tutorial ini. Lihat panduan IIS dalam dokumentasi Microsoft IIS dan artikel ASP.NET Core tentang hosting dengan IIS sebelum menghosting aplikasi produksi di IIS.
Skenario penting untuk hosting IIS yang tidak tercakup dalam tutorial ini meliputi:
- Pembuatan sarang registri untuk Perlindungan Data Inti ASP.NET
- Konfigurasi Daftar Kontrol Akses (ACL) kumpulan aplikasi
- Untuk fokus pada konsep penyebaran IIS, tutorial ini menyebarkan aplikasi tanpa keamanan HTTPS yang dikonfigurasi di IIS. For more information on hosting an app enabled for HTTPS protocol, see the security topics in the Additional resources section of this article. Panduan lebih lanjut untuk menghosting aplikasi ASP.NET Core disediakan di artikel Host ASP.NET Core di Windows dengan IIS .
Memasang .NET Core Hosting Bundle
Instal .NET Core Hosting Bundle di server IIS. Bundel memasang .NET Core Runtime, .NET Core Library, dan ASP.NET Core Module. Modul ini memungkinkan aplikasi ASP.NET Core berjalan di belakang IIS.
Unduh alat penginstal menggunakan tautan berikut:
Alat penginstal .NET Core Hosting Bundle saat ini (unduh langsung)
Jalankan alat penginstal di server IIS.
Mulai ulang server atau jalankan
net stop was /ydiikuti dengannet start w3svcdalam shell perintah.
Membuat situs IIS
Di server IIS, buat folder untuk berisi folder dan file aplikasi yang diterbitkan. Pada langkah berikut, jalur folder disediakan ke IIS sebagai jalur fisik ke aplikasi. Untuk informasi lebih lanjut tentang folder penyebaran dan tata letak file aplikasi, lihat Struktur direktori ASP.NET Core.
In IIS Manager, open the server's node in the Connections panel. Right-click the Sites folder. Select Add Website from the contextual menu.
Provide a Site name and set the Physical path to the app's deployment folder that you created. Provide the Binding configuration and create the website by selecting OK.
Warning
Top-level wildcard bindings (
http://*:80/andhttp://+:80) should not be used. Pengikatan wildcard tingkat atas dapat mengekspos aplikasi Anda terhadap kerentanan keamanan. Ini berlaku untuk wildcard kuat dan lemah. Gunakan nama host eksplisit alih-alih wildcard. Pengikatan wildcard subdomain (misalnya,*.mysub.com) tidak memiliki risiko keamanan ini jika Anda mengontrol seluruh domain induk (alih-alih*.com, yang rentan). Lihat RFC 9110: Semantik HTTP (Bagian 7.2. Host dan :authority) untuk informasi lebih lanjut.Pastikan identitas dari model proses memiliki izin yang tepat.
If the default identity of the app pool (Process Model>Identity) is changed from
ApplicationPoolIdentityto another identity, verify that the new identity has the required permissions to access the app's folder, database, and other required resources. Misalnya, kelompok aplikasi memerlukan akses baca dan tulis ke folder tempat aplikasi membaca dan menulis file.
Membuat aplikasi ASP.NET Core
Buat semua jenis aplikasi berbasis server ASP.NET Core.
Note
Tutorial ini didasarkan pada hosting aplikasi ASP.NET Core sisi server dengan IIS, termasuk Blazor Web App. Untuk panduan tentang menghosting dan menyebarkan aplikasi mandiri Blazor WebAssembly dengan IIS, lihat Menghosting dan menyebarkan ASP.NET Core Blazor WebAssembly dengan IIS.
Menerbitkan dan menyebarkan aplikasi
Menerbitkan aplikasi berarti menghasilkan aplikasi yang dikompilasi yang dapat dihosting oleh server. Menyebarkan aplikasi berarti memindahkan aplikasi yang diterbitkan ke sistem hosting. Langkah penerbitan ditangani oleh .NET Core SDK, sementara langkah penyebaran dapat ditangani oleh berbagai pendekatan. This tutorial adopts the folder deployment approach, where:
- Aplikasi diterbitkan ke folder.
- The folder's contents are moved to the IIS site's folder (the Physical path to the site in IIS Manager).
- Right-click on the project in Solution Explorer and select Publish.
- Dalam dialog Pilih target penerbitan, pilih opsi Terbitkan folder.
- Atur jalur Folder atau Berbagi File.
- Jika Anda membuat folder untuk situs IIS yang tersedia di komputer pengembangan sebagai berbagi jaringan, berikan jalur ke berbagi. Pengguna saat ini harus memiliki akses tulis untuk menerbitkan ke berbagi.
- If you're unable to deploy directly to the IIS site folder on the IIS server, publish to a folder on removable media and physically move the published app to the IIS site folder on the server, which is the site's Physical path in IIS Manager. Move the contents of the
bin/Release/{TARGET FRAMEWORK}/publishfolder to the IIS site folder on the server, which is the site's Physical path in IIS Manager.
- Select the Publish button.
Telusuri situs web
Aplikasi ini dapat diakses di browser setelah menerima permintaan pertama. Buat permintaan ke aplikasi di pengikatan titik akhir yang Anda tetapkan di Manajer IIS untuk situs tersebut.
Next steps
Dalam tutorial ini, Anda mempelajari cara:
- Instal .NET Core Hosting Bundle di Windows Server.
- Buat situs IIS di Manajer IIS.
- Menyebarkan aplikasi ASP.NET Core.
Untuk mempelajari selengkapnya tentang menghosting aplikasi ASP.NET Core di IIS, lihat artikel Gambaran Umum IIS:
Additional resources
Artikel dalam kumpulan dokumentasi ASP.NET Core
- ASP.NET Core Module (ANCM) untuk IIS
- Struktur direktori ASP.NET Core
- Memecahkan masalah ASP.NET Core pada Azure App Service dan IIS
- Menerapkan HTTPS di ASP.NET Core
- WebSocket di IIS
Artikel yang berkaitan dengan penyebaran aplikasi ASP.NET Core
- Menerbitkan aplikasi ASP.NET Core ke Azure dengan Visual Studio
- Menerbitkan aplikasi ASP.NET Core ke Azure dengan Visual Studio Code
- Profil penerbitan Visual Studio (.pubxml) untuk penyebaran aplikasi ASP.NET Core
Artikel tentang konfigurasi HTTPS IIS
Artikel tentang IIS dan Windows Server
Sumber daya penyebaran untuk administrator IIS
- IIS documentation
- Mulai Menggunakan Manajer IIS di IIS
- Penyebaran aplikasi .NET Core
- ASP.NET Core Module (ANCM) untuk IIS
- Struktur direktori ASP.NET Core
- Modul IIS dengan ASP.NET Core
- Memecahkan masalah ASP.NET Core pada Azure App Service dan IIS
- Pemecahan masalah kesalahan umum untuk Azure App Service dan IIS dengan ASP.NET Core
- Sesi lekat dengan Perutean Permintaan Aplikasi
ASP.NET Core