I’m writing some e2e tests for a web application where there is a lot of code I need to interact with that is outside my control. In order to setup my application at the start of each test or group of tests, I intend to use sql scripts to seed the database into a known state and then force the web app to restart so that all internal caches outside my control are all reset.
With that in mind, does anyone know what approach will give me the fastest restart of a web app?
Options I’ve got are:
- Touch the web.config
- Create then remove an app_offline.htm file in the root
- Create some API that can call HttpRuntime.UnloadAppDomain
Are any of these methods faster than any other? Are are they all effectively the same?
Use option # 3:
This method terminates the current application. The application restarts the next time a request is received for it.
See: https://learn.microsoft.com/en-us/dotnet/api/system.web.httpruntime.unloadappdomain?view=netframework-4.8