Showing posts with label delete. Show all posts
Showing posts with label delete. Show all posts

Monday, November 10, 2008

Create and Delete Virtual Directory Programmatically

create a function to create a new virtual directory and set some properties of the new virtual directory.

public void CreateNewVirtualDirectory(int ServerId, string VirtualDirName, string Path, bool AccessScript)
{
DirectoryEntry Parent = new DirectoryEntry(@"IIS://localhost/W3SVC/" + ServerId.ToString() + "/Root");
DirectoryEntry NewVirtualDir;
NewVirtualDir = Parent.Children.Add(VirtualDirName, "IIsWebVirtualDir");
NewVirtualDir.Properties["Path"][0] = Path;
NewVirtualDir.Properties["AccessScript"][0] = AccessScript;NewVirtualDir.CommitChanges();
}
You can call this function like
CreateNewVirtualDirectory(1, "MyNewVirtualDirectory", @"C:\Inetpub\wwwroot\MyDir", true)


create a function to Delete virtual directory .

public void DeleteVirtualDirectory(int ServerId, string VirtualDirName)
{
DirectoryEntry Parent = new DirectoryEntry(@"IIS://localhost/W3SVC/" + ServerId.ToString() + "/Root");
Object[] Parameters = {"IIsWebVirtualDir",VirtualDirName};
Parent.Invoke("Delete",Parameters );
}

Thursday, October 9, 2008

ASP.NET Tab in IIS is Missing

Here are the steps to fix the issue:

1) Stop the IIS Admin service (and any services that depend on it)

2) Open C:\WINDOWS\system32\inetsrv\MetaBase.xml in notepad or your favorite XML

Editor. _DELETE_ the line that reads ‘Enable32BitAppOnWin64=”TRUE”’

3) Start -> Run -> iisreset