How to tell why an IIS application pool is recycled

后端 未结 4 1246
走了就别回头了
走了就别回头了 2020-12-25 14:31

Background:

I\'ve deployed an ASP.NET MVC 3 app that works on my machine to a shared hosting provider and am discovering some problems that appear to be related to

4条回答
  •  轮回少年
    2020-12-25 15:13

    Below is good code find from https://mitchelsellers.com/blog/article/logging-asp-net-application-restarts

    //  obtain the shutdown reason
    System.Web.ApplicationShutdownReason shutdownReason = System.Web.Hosting.HostingEnvironment.ShutdownReason;
    string shutdownDetail = "";
    
    //Evaluate which option caused the error
    switch (shutdownReason)
    {
        case ApplicationShutdownReason.BinDirChangeOrDirectoryRename:
            shutdownDetail = "A change was made to the bin directory or the directory was renamed";
            break;
        case ApplicationShutdownReason.BrowsersDirChangeOrDirectoryRename:
            shutdownDetail = "A change was made to the App_browsers folder or the files contained in it";
            break;
        case ApplicationShutdownReason.ChangeInGlobalAsax:
            shutdownDetail = "A change was made in the global.asax file";
            break;
        case ApplicationShutdownReason.ChangeInSecurityPolicyFile:
            shutdownDetail = "A change was made in the code access security policy file";
            break;
        case ApplicationShutdownReason.CodeDirChangeOrDirectoryRename:
            shutdownDetail = "A change was made in the App_Code folder or the files contained in it";
            break;
        case ApplicationShutdownReason.ConfigurationChange:
            shutdownDetail = "A change was made to the application level configuration";
            break;
        case ApplicationShutdownReason.HostingEnvironment:
            shutdownDetail = "The hosting environment shut down the application";
            break;
        case ApplicationShutdownReason.HttpRuntimeClose:
            shutdownDetail = "A call to Close() was requested";
            break;
        case ApplicationShutdownReason.IdleTimeout:
            shutdownDetail = "The idle time limit was reached";
            break;
        case ApplicationShutdownReason.InitializationError:
            shutdownDetail = "An error in the initialization of the AppDomain";
            break;
        case ApplicationShutdownReason.MaxRecompilationsReached:
            shutdownDetail = "The maximum number of dynamic recompiles of a resource limit was reached";
            break;
        case ApplicationShutdownReason.PhysicalApplicationPathChanged:
            shutdownDetail = "A change was made to the physical path to the application";
            break;
        case ApplicationShutdownReason.ResourcesDirChangeOrDirectoryRename:
            shutdownDetail = "A change was made to the App_GlobalResources foldr or the files contained within it";
            break;
        case ApplicationShutdownReason.UnloadAppDomainCalled:
            shutdownDetail = "A call to UnloadAppDomain() was completed";
            break;
        default:
            shutdownDetail = "Unknown shutdown reason";
            break;
    }
    

提交回复
热议问题