我在IIS中部署了Asp.Net网站(非Web应用程序模板)项目。防病毒扫描应用程序。所以,客户面临退出问题。我已经在SO
上遇到了类似的问题每当我遇到注销问题时,我都可以在事件查看器中看到以下错误
Event message: Application is shutting down. Reason: A subdirectory in the Bin application directory was changed or renamed.
在@Zaitsman的帮助下,我提出了以下代码(global.asax的代码)来解决问题
<%@ import namespace="System.Reflection"%>
private static bool hasRemovedFoldersFromMonitoring = false;
protected void Application_AcquireRequestState(object sender, EventArgs e)
{
if (!hasRemovedFoldersFromMonitoring)
{
PropertyInfo fcmPi = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
object o = fcmPi.GetValue(null, null);
FieldInfo fi_dirMonSubdirs = o.GetType().GetField("_dirMonSubdirs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase);
object monitor_dirMonSubdirs = fi_dirMonSubdirs.GetValue(o);
MethodInfo m_dirMonSubdirs = monitor_dirMonSubdirs.GetType().GetMethod("StopMonitoring", BindingFlags.Instance | BindingFlags.NonPublic);
m_dirMonSubdirs.Invoke(monitor_dirMonSubdirs, new object[] { });
FieldInfo fi_dirMonAppPathInternal = o.GetType().GetField("_dirMonAppPathInternal", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase);
object monitor_dirMonAppPathInternal = fi_dirMonAppPathInternal.GetValue(o);
if (monitor_dirMonAppPathInternal != null)
{
MethodInfo m_dirMonAppPathInternal = monitor_dirMonAppPathInternal.GetType().GetMethod("StopMonitoring", BindingFlags.Instance | BindingFlags.NonPublic);
m_dirMonAppPathInternal.Invoke(monitor_dirMonAppPathInternal, new object[] { });
}
hasRemovedFoldersFromMonitoring = true;
}
}
但是,代码无法解决问题。我仍然在注销问题。
我还尝试在注册表编辑器上禁用FCNMode,如下所示:
HKLM\Software\Microsoft\ASP.NET\FCNMode
Added the DWORD value of 1 to FCNMode
我仍然面临着这个问题。
有人可以帮我解决这个IIS注销问题吗?我想通过编码来解决这个问题。
下面我没问题:
通过这种方式,如果在IIS部署后不会自动识别代码更改。然后很好,我会为此手动重启IIS。但是,我希望应用程序不应该在会话超时之前为客户注销。
提前致谢!