简体   繁体   中英

.NET Core Web Deploy to production takes down site while publishing?

I have a .NET Core website using IISIntegration():

 var contentRoot = Directory.GetCurrentDirectory();
 var host = new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(contentRoot)
            .UseSetting("detailedErrors", "true")
            .UseIISIntegration()
            .UseStartup<Startup>()
            .CaptureStartupErrors(true)
            .Build();

And when I am publishing using web deploy, the site publishes quickly because it's not large now, but there is a 2 second or so period where if you try and access the site on production while that publish occurs (when it actually copies the files) that the site is down and you get a blank white page with the title saying "Site Under Construction".

This isn't like the old EF 4.x, where when you publish to an already running site, the site would just spin and try to load while publishing was occurring, but eventually the request would go through and load after publishing was done.

I can't seem to find any mention of this or any other questions about this specific issue, does no one else have this issue and what's the workaround? Our team publishes often in the middle of the day to do fast iteration on bug fixes (we are very small shop), but we can't have the site go down a few seconds (or presumably longer if the site becomes larger) each time we publish.

The deployment process places a app_offline.htm file in the folder while the deployment is running. If the ASP.NET Core module finds this file, it shuts down your application and instead returns the contents of this file for all requests.

References:
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.2#locked-deployment-files
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-2.2#app_offlinehtm

You might be able to disable this behavior by setting <EnableMSDeployAppOffline>False</EnableMSDeployAppOffline> in your publish profile, but I haven't tested if this actually works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM