Process of Publishing and Updating Your ASP.NET Core Application with SQL Server on IIS
Learn the complete process of publishing and updating your ASP.NET Core application with SQL Server on a network server using IIS. Even if you're new to this, follow the guide below to ensure a smooth deployment and update.
Prerequisites
- Server Access: Administrative access to the server running IIS.
- Development Tools: Visual Studio with the ASP.NET workload or the .NET CLI.
- Source Code: The latest code version to be published.
Step-by-Step Publishing and Updating Guide
1. Backup the Existing Application (Recommended)
Before updating, back up the current application to ensure you can revert if needed:
- - In IIS Manager, go to the website or application pool hosting your application.
- - Right-click and select Stop to halt the application.
- - Copy the application’s published files to a safe location on your local machine.
2. Publish the Updated Application
Follow these steps to publish your updated application:
- - Open your ASP.NET Core project in Visual Studio.
- - Right-click the project and select Publish.
- - Choose Folder as the publish target and select a location.
- - Set the Configuration to Release and click Publish.
3. Verify Published Files
Ensure all necessary files are in the publish_folder
, including folders like bin and wwwroot.
4. Copy Files to the Server
Use a secure file transfer tool to copy the published files from your local machine to the server.
5. Configure or Update IIS Application
Open IIS Manager and choose one of the following options:
- - Update Existing Application: Edit the physical path to point to the updated folder.
- - Create a New Website: Define the physical path, hostname, and port for a fresh setup.
6. Configure Application Pool (Optional)
Set up or update the application pool for your application:
- - Create a new pool or select an existing one in IIS.
- - Select No Managed Code for ASP.NET Core 3.1+ versions.
7. Install .NET Core Hosting Bundle
Download and install the .NET Core Hosting Bundle if it’s not already installed on the server.
8. Enable 32-Bit Applications (If Necessary)
If your application requires 32-bit compatibility, enable it in the Application Pool settings.
9. Start the Application Pool and Website
- - Right-click the application pool and select Start.
- - Start the website and verify functionality by navigating to the URL.
Additional Considerations
- - Connection Strings: Update database connection strings in
appsettings.json
if necessary. - - Permissions: Ensure the application pool user has the necessary file and database permissions.
- - Troubleshooting: Check server and application logs in the Event Viewer for error details.
By following this guide, you can efficiently publish and update your ASP.NET Core application with SQL Server on IIS. Don’t forget to test the application before making it publicly accessible.