Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > deleting mediaLibary folrder triggers app restart View modes: 
User avatar
Member
Member
eagleag - 6/2/2013 5:08:31 AM
   
deleting mediaLibary folrder triggers app restart
This is the Delete folder code (it works, folder is deleted):
 [WebMethod]
public static void DeleteDirectory(string LibraryName, string FolderPath)
{
EventLogProvider eventLog = new EventLogProvider();
MediaLibraryInfo libraryInfo = MediaLibraryInfoProvider.GetMediaLibraryInfo(LibraryName, CMSContext.CurrentSiteName);
MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(libraryInfo, "folderdelete");

FolderPath = Regex.Replace(FolderPath, @"[^0-9a-zA-Z\\._]", string.Empty);

FolderPath = FolderPath.Substring(FolderPath.IndexOf("\\") + 1);
try
{
MediaLibraryInfoProvider.DeleteMediaLibraryFolder(CMSContext.CurrentSiteName, libraryInfo.LibraryID, FolderPath, false);

eventLog.LogEvent("I", DateTime.Now, "OP - Documents -> delete folder", "OP - DOCS DELETE FOL", CMSContext.CurrentUser.UserID, CMSContext.CurrentUser.UserName, 0, "", "", "OP - mediaLibrary:" + LibraryName + ", fodler: " + FolderPath + " -> was deleted", CMSContext.CurrentSiteID, "CMSModules\\MediaLibrary\\MediaLibraryServicePage.aspx.cs");

}
catch (Exception exx)
{

eventLog.LogEvent("E", DateTime.Now, "OP - Documents -> delete folder", "OP - DOCS DELETE FOL", CMSContext.CurrentUser.UserID, CMSContext.CurrentUser.UserName, 0, "", "", "OP - mediaLibrary:" + LibraryName + ", fodler: " + FolderPath + " -> ERROR when trying to delete. Exception msg:" + exx.Message, CMSContext.CurrentSiteID, "CMSModules\\MediaLibrary\\MediaLibraryServicePage.aspx.cs");

}
}

this is the what happens after folder deleted:
E 6/2/2013 12:56:12 PM Application_End EXCEPTION
Description: Message: Directory rename change notification for 'C:\svn\kentico\siteName'.
cagan dir change or directory rename
HostingEnvironment initiated shutdown
HostingEnvironment caused shutdown

Shutdown stack: at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Web.Hosting.HostingEnvironment.InitiateShutdownInternal()
at System.Web.Hosting.HostingEnvironment.InitiateShutdown()
at System.Web.HttpRuntime.ShutdownAppDomain(String stackTrace)
at System.Web.HttpRuntime.OnCriticalDirectoryChange(Object sender, FileChangeEvent e)
at System.Web.FileChangesMonitor.OnSubdirChange(Object sender, FileChangeEvent e)
at System.Web.DirectoryMonitor.FireNotifications()
at System.Web.Util.WorkItem.CallCallbackWithAssert(WorkItemCallback callback)
at System.Web.Util.WorkItem.OnQueueUserWorkItemCompletion(Object state)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)

Call stack: at Global.LogApplicationEnd()
at Global.Application_End(Object sender, EventArgs e)
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Web.HttpApplication.ProcessSpecialRequest(HttpContext context, MethodInfo method, Int32 paramCount, Object eventSource, EventArgs eventArgs, HttpSessionState session)
at System.Web.HttpApplicationFactory.FireApplicationOnEnd()
at System.Web.HttpApplicationFactory.Dispose()
at System.Web.HttpRuntime.Dispose()
at System.Web.HttpRuntime.ReleaseResourcesAndUnloadAppDomain(Object state)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)

Machine name:
Event URL:

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 6/3/2013 6:29:44 AM
   
RE:deleting mediaLibary folrder triggers app restart
Hello,

This behaviour could be caused by IIS settings...

- The application pool in IIS can be set to recycle the application if some limits are exceeded - CPU usage, Memory, idle time.

- .Net is restarting application automatically when there is a change in web.config file, BIN, App_Code directory and other directories (you can find complete list using Google). From the error message it seems that some directory on file system in the web project folder was changed and this invoked the restart of the application. This is the standard .Net behaviour

I would also recommend you to read the following article: Ten leading causes ASP.NET to restart the site

And also... are you running any anti-virus software?

Best regards,
Martin Danko

User avatar
Member
Member
eagleag - 6/3/2013 1:30:07 PM
   
RE:deleting mediaLibary folrder triggers app restart
Thanks for your detailed answer.

My code does DELETE a Folder in the web project and from what I understand from you, it causes application restart.

I noticed it also happens when I delete a folder throw cmsdesk -> tools -> media library.

Is there anyway to change this from happening? no need to restart app when we DELETE a media library folder.

Thanks

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 6/7/2013 9:11:03 AM
   
RE:deleting mediaLibary folrder triggers app restart
Hi,

Could you please answer also my last question... are you running any anti-virus software?

Best regards,
Martin Danko