Wei Lin
Wei Lin

Reputation: 3821

How to update ASP.NET Core files without stop IIS Application & Pool in .NET5?

Every time need to stop the IIS Application or Pool to update

or system will show The action can't be completed becacuse the file is open in w3wp.exe

I expect like asp.net or mvc, you don't need to stop IIS to update.


Right now my way, I drop a file called app_offline.htm (case sensitive) to my application folder. Let IIS auto stop my application then I update it

From this article iis - How can I update ASP.NET Core app over an existing/running site without stopping the web server? - Stack Overflow

Upvotes: 4

Views: 3325

Answers (2)

Marcin
Marcin

Reputation: 490

I found solution for asp.net core but I am not quite happy with it. Maybe it would be fine for big project with lots of files to copy.

  • upload app_offline.htm with site update message
  • change appPool to other i.e DefaultAppPool
  • delete web.config
  • stop appPool for my app (this part takes literally minutes)
  • publish new version
  • change appPool back to my app and start it
  • restore web.config

Useful Windows Commands:

%SYSTEMROOT%\System32\inetsrv\appcmd list app

%SYSTEMROOT%\System32\inetsrv\appcmd set app /app.name:"[MyAppName/]" /applicationPool:DefaultAppPool

%SYSTEMROOT%\System32\inetsrv\appcmd set app /app.name:"[MyAppName/]" /applicationPool:[MyAppPool]

%SYSTEMROOT%\System32\inetsrv\appcmd stop apppool /apppool.name:"[MyAppPool]"

%SYSTEMROOT%\System32\inetsrv\appcmd start apppool /apppool.name:"[MyAppPool]"

Upvotes: 0

Ding Peng
Ding Peng

Reputation: 3974

If we use asp.net core, we cannot achieve non-stop update projects.

When IIS is running your website process, if a request comes in at this time, the dll/exe file will be locked. If an update item is released at this time, the dll/exe cannot be replaced successfully and an error will be reported.

As for why asp.net can achieve uninterrupted updates, because the difference between core and asp.net is that asp.net applications are completely deployed in IIS, while asp.net core uses IIS as a proxy server. We can think of the core application as a console application. So to update the asp.net core application must stop IIS.

The solution I thought of was to provide a transition site.

Upvotes: 8

Related Questions