Search code examples
c#asp.net.netappdomain

Does ASP.Net ever run in the default AppDomain?


I've got an interesting situation where I want to make sure I'm not running in the default AppDomain on an ASP.Net Web Api service (apparently RazorEngine has issues locking temporary files if running in the default AppDomain). From what I can see, by the time Application_Start runs, it's already not in the default AppDomain.

Checked using: AppDomain.CurrentDomain.IsDefaultAppDomain() returns false

Are there any situations where ASP.Net will run in the default AppDomain?


Solution

  • Hi There is no way for user code to have access to the default CLR AppDomain in ASP.NET. The ASP.NET runtime does however use the default AppDomain for some things but it creates a specific AppDomain for running user code. That's why IsDefaultAppDomain returns false and always will :)

    Hope this helps!