Menu

#6 Accessing website settings when user had deleted directory

open
nobody
None
5
2010-04-26
2010-04-26
Webio
No

Hello,

Probably a lot of you had support tickets that user can't delete his website from panel. 90% of this type of incidents are related to deleting whole directory before removing website from user control panel. I've created workaround for this but this is lets call it alpha version and I hope someone can update it.

Modifications:

WebsitePanel\Trunk\Sources\WebsitePanel.Providers.Web.IIS70\IIs70.cs

Added:

inside public override WebSite GetSite(string siteId)

string mainDirectory = site.LogsPath.Replace(@"\logs", "");
if (!FileUtils.DirectoryExists(mainDirectory))
{
FileUtils.CreateDirectory(mainDirectory);
FileUtils.CreateDirectory(String.Format("{0}/logs", mainDirectory));
FileUtils.CreateDirectory(String.Format("{0}/data", mainDirectory));
FileUtils.CreateDirectory(String.Format("{0}/wwwroot", mainDirectory));
// set folder permissions
SetWebFolderPermissions(site.ContentPath, GetNonQualifiedAccountName(site.AnonymousUsername), site.EnableWritePermissions, site.DedicatedApplicationPool);
// set DATA folder permissions
SetWebFolderPermissions(site.DataPath, GetNonQualifiedAccountName(site.AnonymousUsername), true, site.DedicatedApplicationPool);
}

it creates missing directory structure but it looks like website binding must be called again from Portal to bind properly so we need to modify Portal source too:

WebsitePanel\Trunk\Sources\WebsitePanel.WebPortal\DesktopModules\WebsitePanel\WebSitesEditSite.ascx.cs

inside private void BindWebSite()

Changed handling of website error to redirect to websites view when exception will occur:

catch (Exception ex)
{
RedirectSpaceHomePage();
//ShowErrorMessage("WEB_GET_SITE", ex);
return;
}

It would be good to catch exception type and only redirects to websites list or even reload the same page (using Response.Redirect(Request.RawUrl);) if error was related to missing directory.

Discussion

  • Webio

    Webio - 2010-04-26
     
  • Webio

    Webio - 2010-04-26
     
  • Webio

    Webio - 2010-04-26

    P.S. I'm using "site.LogsPath" because any other site.(path containing variable) does not contain any data

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.