Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force ASP.Net to invalid (and thus reload) the current application instance?

Tags:

asp.net

Basically I want the effect that would occur if I were to edit the web.config file. The application basically completely unloads itself and starts again, thus re-firing Application_Start and also ditching any dynamically created Types created by the now-defunct AppDomain.

EDIT

I need to do this in my C# code inside my web application. I know it can be done; I did it ages ago but have since lost the code and forgotten how I did it.

like image 485
Nathan Ridley Avatar asked Dec 29 '22 20:12

Nathan Ridley


1 Answers

For full trust you can use HttpRuntime.UnloadAppDomain(). If you aren't running in full trust you can modify the last write time on the web.config file. Rick Strahl has wrapped these two approaches up in a nice class.

like image 79
RichardOD Avatar answered Feb 05 '23 16:02

RichardOD