簡體   English   中英

如何找出為什么Application_End在Azure App Service上觸發

[英]How to find out why Application_End is firing on Azure App Service

我們在Azure上托管了一個MVC ASP.NET Web應用程序作為應用程序服務。 每天3到4次,我可以看到它重新啟動了。 我在global.asax的Application_End()中記錄了System.Web.HostingEnvrionment.ShutdownReason ,原因返回為“配置更改”,根據文檔,這意味着應用程序配置已更改。

我已經問過我們的小型團隊,沒有人手動更改配置。 弄清代碼后,我看不到我們以編程方式對其進行更改的任何地方。 天藍色站點配置為始終打開。 內存使用在發生時並沒有達到極限,盡管它似乎在較高的通信時間內更頻繁地發生。

是否有辦法獲取更改的特定文件,以便可以將其記錄在Application_End() 還是任何其他方式來獲取更多細節?

Scott Guthrie的博客文章介紹如何使用反射從Application Shut Down事件中獲取更多信息 我將詳細閱讀他的文章,以查找有關問題的更多信息。

下面是斯科特頁面上用於提取更多信息的代碼段。 然后,您可以使用所使用的任何工具對其進行記錄。

 HttpRuntime runtime = (HttpRuntime)typeof(System.Web.HttpRuntime)
                                                  .InvokeMember("_theRuntime",
                                                                 BindingFlags.NonPublic
                                                                 | BindingFlags.Static
                                                                 | BindingFlags.GetField,
                                                                 null,
                                                                 null,
                                                                 null);

 if (runtime == null)
     return;

 string shutDownMessage = (string)runtime.GetType().InvokeMember("_shutDownMessage",
                                                                 BindingFlags.NonPublic
                                                                |BindingFlags.Instance
                                                                |BindingFlags.GetField,
                                                                         null,
                                                                         runtime,
                                                                         null);

 string shutDownStack = (string)runtime.GetType().InvokeMember("_shutDownStack",
                                                                 BindingFlags.NonPublic
                                                                | BindingFlags.Instance
                                                                | BindingFlags.GetField,
                                                                       null,
                                                                       runtime,
                                                                       null);

注釋中提到您可能需要對代碼具有某些權限才能執行私有反射。

祝您好運,我希望這可以幫助您更進一步解決問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM