Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dynamically patch a running ASP.NET application?

Tags:

asp.net

patch

Does anyone have a sample of how to patch a running asp.net app? The scenario I'm envisioning is that the app could look to a known central server for newer versions. Download the newer files to a temp location and then patch itself.

The issues that I can see are that any file changes will get picked up by the file watcher and reload the app domain which would stop the current patching process. I think that each file written would trigger a reload of the app.

like image 630
Marcus McConnell Avatar asked Jul 17 '09 20:07

Marcus McConnell


2 Answers

Unless you're doing some file watching on specific files, you can update existing aspx files without any application slowdown. The next time the user refreshes the browser, they'll see the page update. Be careful though, if you have added additional server controls to the page, and the DLL hasn't been updated yet, you'll run into problems.

If you update the web.config or DLL files for the application, this will trigger a reload of the ASPNET worker process, and any new users will suffer the "first lag" that you can typically expect.

If you are worried about this process, and can afford a bit of "down time" I'd suggest you create a script that does the following:

  1. Upload a file named App_Offline.htm to the root of the web application. IIS will immediately see this file and redirect users to it, and not do any .NET processing. You can even keep a file named App_Offline_Disabled.htm in the root folder and simply rename it when the time is right.

  2. Copy all your files in that need to be updated, overwriting/renaming/copying as necessary.

  3. Remove (or rename) your App_Offline.htm file so that IIS will start directing users to the updated application. If you're watching the script run, you can even go hit the website yourself to take that "first load" penalty so your end users will see things nice and crisp as always.

Again, I don't know if you can afford the down time on the site in this manner, but I see the process itself as easily scriptable to provide for a nice automated type process.

like image 75
Dillie-O Avatar answered Oct 03 '22 02:10

Dillie-O


What do you mean by patching?

If you mean updating, you can simply copy updates files to application directory. Currently active requests will be fully served using the last compiled version of your application, then it will be recompiled to serve the consequent requests. Nothing special is required really.

like image 39
User Avatar answered Oct 03 '22 03:10

User