Since dotnet loads .dll/.exe files in an individual process to serve the application service, the .dll/.exe file is locked and cannot be successfully replaced when the app is running. It is recommended to stop the ASP.NET Core app before updating the files through web deploy, FTP, HTTP upload or unzip in the Control Panel's File Manager.
The first way to stop the app is:
by using the App Offline file (app_offline.htm). This file is used by the ASP.NET Core Module to shut down an app. You can manually create/upload an "app_offline.htm" in the production site's root directory. If a file with the name app_offline.htm is detected in the root directory of an app, the ASP.NET Core Module attempts to gracefully shut down the app and stop processing incoming requests.
While the app_offline.htm file is present, the ASP.NET Core Module responds to requests by sending back the contents of the app_offline.htm file. The app_offline.htm file must be less than 4 GB. When the app_offline.htm file is removed, the next request starts the app.
When using the out-of-process hosting model, the app might not shut down immediately if there's an open connection. For example, a WebSocket connection may delay app shut down. In such cases, you can use the second way to stop the app.
The second way to stop the app is:
to turn off the target site from your Control Panel. Go to Websites, click the "..."(three dot icon button) to manage website, and select Site On/Off. This will stop the IIS entry and refuse all requests to this site.
Restart your application pool from your Control Panel by going to Server Overview > Restart Pool, or Control Panel > Advance > Pool Manager > Actions > Restart Pool (or stop pool and then start pool). This will kill all running processes associated with your app pool and release all in-use files.
Now you will be able to update/replace/overwrite any files in the target site's directory via web deploy, FTP, or HTTP upload in the Control Panel's File Manager. Remember to remove the app_offline.htm file and start the site after updating.
References: